#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1000000007;
const int inf = 1e9 + 10;
const long long INF = 1e18;
inline void add(int &a, int b) {
  a = a + b;
  if (a >= mod) a -= mod;
}
inline void mul(int &a, int b) {
  long long t = 1LL * a * b;
  if (t >= mod) t %= mod;
  a = t;
}
int pw(int x, int p) {
  if (p == 0) return 1;
  int res = 1;
  while (p > 0) {
    if (p & 1) mul(res, x);
    p >>= 1;
    mul(x, x);
  }
  return res;
}
int n;
int cnt[maxn];
vector<int> divisors[maxn];
int dp[200][maxn][2];
int MAIN() {
  scanf("%d", &n);
  int mx = -1;
  for (int i = 0; i < n; ++i) {
    int d;
    scanf("%d", &d);
    mx = max(mx, d);
    ++cnt[d];
  }
  for (int i = mx - 1; i >= 1; --i) {
    cnt[i] += cnt[i + 1];
  }
  for (int i = 1; i <= mx; ++i) {
    for (int j = i; j <= mx; j += i) divisors[j].push_back(i);
  }
  int maxd = -1;
  for (int i = 1; i <= mx; ++i) {
    maxd = max(maxd, (int)divisors[i].size());
  }
  for (int k = 1; k <= maxd; ++k) {
    dp[k][0][0] = 1;
    dp[k][0][1] = 0;
    for (int i = 1; i <= n; ++i) {
      dp[k][i][1] = dp[k][i - 1][0] + (1LL * dp[k][i - 1][1] * k) % mod;
      dp[k][i][1] %= mod;
      dp[k][i][0] = (1LL * dp[k][i - 1][0] * (k - 1)) % mod;
    }
  }
  int ans = 0;
  for (int i = 1; i <= mx; ++i) {
    int sz = divisors[i].size();
    int t = 1;
    for (int j = 0; j < sz; ++j) {
      if (j < sz - 1) {
        mul(t, pw(j + 1, cnt[divisors[i][j]] - cnt[divisors[i][j + 1]]));
      } else {
        mul(t, dp[sz][cnt[divisors[i][j]]][1]);
      }
    }
    add(ans, t);
  }
  printf("%d\n", ans);
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  cout << fixed << setprecision(16);
  int ret = MAIN();
  return ret;
}
