#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long mod = 1e9 + 7;
int a[N], n, sum[N], num, j;
long long ans, sm;
vector<int> v[N];
long long ksm(long long x, int y) {
  long long sun = 1;
  while (y) {
    if (y & 1) sun = sun * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return sun;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum[a[i]]++;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= a[n]; i++) {
    sum[i] += sum[i - 1];
    for (j = 1; j * i <= a[n]; j++) v[j * i].push_back(i);
  }
  for (int i = 1; i <= a[n]; i++) {
    sm = 1;
    for (j = 1; j < v[i].size(); j++)
      sm = sm * ksm(j, sum[v[i][j] - 1] - sum[v[i][j - 1] - 1]) % mod;
    num = sum[a[n]] - sum[v[i][j - 1] - 1];
    sm = sm * ((ksm(j, num) - ksm(j - 1, num) + mod) % mod) % mod;
    ans = (ans + sm) % mod;
  }
  cout << ans;
}
