#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 10;
int freq[N], a[N], sum[N], prod[N];
vector<int> p;
long long binpow(long long x, long long y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  long long sol = binpow(x, y / 2);
  sol *= sol;
  if (sol >= MOD) sol %= MOD;
  if (y % 2) sol *= x;
  return sol % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, mx = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
    freq[a[i]]++;
  }
  for (int i = 1; i < N; i++) sum[i] = sum[i - 1] + freq[i];
  long long ans = 0LL;
  for (int i = 1; i <= mx; i++) {
    p.clear();
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        p.push_back(j);
        if (j * j != i) p.push_back(i / j);
      }
    }
    sort(p.begin(), p.end());
    int cnt;
    for (int j = 0; j < p.size(); j++) {
      if (j == p.size() - 1)
        cnt = sum[N - 1] - sum[p[j] - 1];
      else
        cnt = sum[p[j + 1] - 1] - sum[p[j] - 1];
      prod[j] = cnt;
    }
    long long rez = 1;
    for (int j = 0; j < p.size(); j++) {
      if (j == p.size() - 1) {
        long long c1 = binpow(j + 1, 1LL * prod[j]);
        long long c2 = binpow(j, 1LL * prod[j]);
        rez *= (c1 - c2 + MOD) % MOD;
      } else {
        rez *= binpow(j + 1, 1LL * prod[j]);
      }
      if (rez >= MOD) rez %= MOD;
    }
    ans += rez;
    if (ans >= MOD) ans %= MOD;
  }
  cout << ans;
  return 0;
}
