#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 15;
long long n, a[MAXN], mod = 1e9 + 7, psum[MAXN], cnt[MAXN], x, ans, y;
vector<long long> d[MAXN];
long long pw(long long base, long long power) {
  y = 1;
  while (power) {
    if (power % 2) {
      y *= base;
      y %= mod;
    }
    base *= base;
    base %= mod;
    power /= 2;
  }
  return y;
}
int main() {
  for (long long i = 1; i <= 100000; i++)
    for (long long j = i; j <= 100000; j += i) d[j].push_back(i);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], cnt[a[i]]++;
  sort(a, a + n);
  for (int i = 100000; i > 0; i--) psum[i] = psum[i + 1] + cnt[i];
  for (int i = 1; i <= 100000; i++) {
    if (!psum[i]) continue;
    if (i > a[n - 1]) continue;
    x = 1;
    for (int j = 1; j < d[i].size(); j++) {
      x *= pw(j, psum[d[i][j - 1]] - psum[d[i][j]]);
      x %= mod;
    }
    x *= (pw(d[i].size(), psum[d[i][d[i].size() - 1]]) -
          pw(d[i].size() - 1, psum[d[i][d[i].size() - 1]]) + mod) %
         mod;
    x %= mod;
    ans += x;
    ans %= mod;
  }
  cout << ans << '\n';
}
