#include <bits/stdc++.h>
using namespace std;
long long a[100005], mod = 1e9 + 7;
vector<long long> p[100005];
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return res % mod;
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  for (long long i = a[n]; i >= 1; i--) {
    for (int j = i; j <= a[n]; j += i) {
      p[j].push_back(i);
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= a[n]; i++) {
    long long now = n + 1, l = p[i].size(), t = 1;
    for (auto j : p[i]) {
      long long v = lower_bound(a + 1, a + 1 + n, j) - a;
      if (j == i)
        t = (t % mod * ((qpow(l, now - v) - qpow(l - 1, now - v)) % mod + mod) %
             mod) %
            mod;
      else
        t = t % mod * qpow(l, now - v) % mod;
      now = v;
      l--;
    }
    ans += t;
    ans %= mod;
  }
  cout << ((ans % mod) + mod) % mod << endl;
}
