#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 100, OO = 1e18, M = 1e9 + 7, M2 = 998244353, sq = 350,
                lg = 23;
long long a[N], n, dp[N], ans = 0, mx = 0;
long long pw(long long x, long long y) {
  if (y == 0) return 1;
  long long cnt = pw(x, y / 2);
  cnt = (cnt * cnt) % M;
  cnt = (cnt * (y % 2 == 1 ? x : 1)) % M;
  cnt %= M;
  return cnt;
}
void solve(long long x) {
  vector<long long> v;
  for (long long j = 1; j * j <= x; j++) {
    if (j * j == x)
      v.push_back(j);
    else if (x % j == 0)
      v.push_back(x / j), v.push_back(j);
  }
  sort(v.begin(), v.end());
  long long cnt = 1;
  for (long long i = 1; i < v.size(); i++) {
    cnt *= pw(i, dp[v[i] - 1] - dp[v[i - 1] - 1]);
    cnt %= M;
  }
  long long cnt2 = cnt;
  cnt *= pw(v.size(), dp[a[n - 1]] - dp[v[v.size() - 1] - 1]) % M;
  cnt2 *= pw(v.size() - 1, dp[a[n - 1]] - dp[v[v.size() - 1] - 1]) % M;
  cnt %= M;
  cnt2 %= M;
  cnt -= cnt2;
  cnt += M;
  cnt %= M;
  ans += cnt;
  ans %= M;
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long t = 0;
  for (long long i = 0; i < n; i++) {
    while (t < a[i]) {
      t++;
      dp[t] = dp[t - 1];
    }
    dp[t]++;
  }
  dp[a[n - 1] + 1] = dp[a[n - 1]];
  for (long long i = 2; i <= a[n - 1]; i++) solve(i);
  ans %= M;
  cout << ans + 1 << endl;
  return 0;
}
