#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7, maxn = 1e5 + 10;
long long int n, m, k, x, h, y, q, ans, ps[maxn];
std::vector<long long int> v[maxn];
long long int bpow(long long int a, long long int b) {
  if (!b) return 1;
  x = bpow(a, b / 2);
  x = (1ll * x * x) % M;
  if (b & 1) x = (1ll * x * a) % M;
  return x;
}
int32_t main() {
  for (long long int i = 1; i < maxn; i++) {
    for (long long int j = i; j < maxn; j += i) {
      v[j].push_back(i);
    }
  }
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    ps[a[i] + 1]++;
    m = max(m, a[i]);
  }
  for (long long int i = 1; i < maxn; i++) {
    ps[i] += ps[i - 1];
  }
  for (long long int i = 1; i <= m; i++) {
    k = 1, q = v[i].size();
    for (long long int j = 1; j < q; j++) {
      long long int t = ps[v[i][j]] - ps[v[i][j - 1]];
      k = (k * bpow(j, t)) % M;
    }
    if (q > 1)
      k *= (bpow(q, n - ps[v[i][q - 1]]) - bpow(q - 1, n - ps[v[i][q - 1]]) +
            M) %
           M;
    ans = (ans + k) % M;
  }
  cout << ans;
  return 0;
}
