#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long t = power(a, b / 2);
  t = (t * t) % 1000000007;
  if (b & 1) t = (t * a) % 1000000007;
  return t;
}
vector<int> divs[100002];
int cnt[100002];
inline void init() {
  for (int i = 1; i < 100002; i++) {
    for (int j = i; j < 100002; j += i) {
      divs[j].push_back(i);
    }
  }
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  int m = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    m = max(m, a[i]);
  }
  for (int i = 1; i < 100002; i++) {
    cnt[i] += cnt[i - 1];
  }
  init();
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    long long res = 1;
    for (int j = 0; j < divs[i].size() - 1; j++) {
      int p1 = divs[i][j], p2 = divs[i][j + 1];
      int q = cnt[p2 - 1] - cnt[p1 - 1];
      res = (res * power(j + 1, q)) % 1000000007;
    }
    int k = divs[i].size();
    int q = cnt[100002 - 1] - cnt[i - 1];
    res = (res * ((power(k, q) - power(k - 1, q) + 1000000007) % 1000000007)) %
          1000000007;
    ans = (ans + res) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
