#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, a[N];
vector<long long> v[N];
long long ans = 0;
void ini() {
  for (long long i = N - 1; i >= 1; --i) {
    long long x = i;
    for (long long j = 1; j * j <= x; ++j) {
      if (x % j == 0) {
        v[x].push_back(j);
        if (x / j != j) v[x].push_back(x / j);
      }
    }
    sort(v[x].begin(), v[x].end());
  }
}
long long me(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) res = ((res % 1000000007) * (x % 1000000007)) % 1000000007;
    x = (x * x) % 1000000007;
    n /= 2;
  }
  return res % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  std::ios::sync_with_stdio(false);
  cin >> n;
  ini();
  long long mx = 0;
  for (long long i = 1; i < n + 1; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  sort(a + 1, a + n + 1);
  long long i, j;
  for (i = 1; i <= mx; ++i) {
    long long b, c = 1, ji = 1;
    for (j = 1; j < v[i].size(); ++j) {
      b = lower_bound(a + 1, a + n + 1, v[i][j]) - a;
      ji = ji * (me(j, b - c)) % 1000000007;
      c = b;
    }
    ans = (ans % 1000000007 +
           ji *
               (me(j, n - c + 1) % 1000000007 -
                me(j - 1, n - c + 1) % 1000000007 + 1000000007) %
               1000000007) %
          1000000007;
    ans %= 1000000007;
  }
  ans %= 1000000007;
  cout << ans;
}
