#include <bits/stdc++.h>
using namespace std;
long long poww(long long a, long long p) {
  if (p == 1) return a % 1000000007;
  if (p == 0) return 1LL;
  long long val = poww(a, p / 2);
  if (p % 2)
    return (((val * val) % 1000000007) * a) % 1000000007;
  else
    return (val * val) % 1000000007;
}
long long n, a[100005], ans;
vector<long long> f, q;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  a[0] = -1;
  for (long long i = 1; i <= a[n]; ++i) {
    if (i == 1) {
      ans += 1;
      continue;
    }
    f.clear();
    q.clear();
    for (long long j = 1; j <= sqrt(i); ++j) {
      if (i % j == 0) {
        f.push_back(j);
        if (i / j != j) f.push_back(i / j);
      }
    }
    sort(f.begin(), f.end());
    f.push_back(a[n] + 1);
    long long idx, sum = 0;
    for (long long j = 0; j <= f.size() - 2; ++j) {
      idx = lower_bound(a + 1, a + n + 1, f[j + 1]) - a - 1;
      q.push_back(idx - sum);
      sum = idx;
    }
    long long val = 1;
    for (long long j = 0; j <= q.size() - 2; ++j) {
      val = (val * poww(j + 1, q[j])) % 1000000007;
    }
    val = (val * ((poww(q.size(), q[q.size() - 1]) -
                   poww(q.size() - 1, q[q.size() - 1]) + 1000000007) %
                  1000000007)) %
          1000000007;
    ans = (ans + val) % 1000000007;
  }
  cout << ans << endl;
}
