#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
int maxx = 1e5;
vector<int> fact[200005];
;
long long pre[2000005];
long long mod = 1e9 + 7;
long long memo[200005][2];
long long solve(int i, int ok) {
  if (i == 0) {
    return 0;
  }
  long long &ret = memo[i][ok];
  if (ret != -1) return ret;
  ret = 0;
  if (ok) {
    ret += solve(i - 1, ok);
    ret %= mod;
    ret += solve(i - 1, ok) + 1;
    ret %= mod;
  } else {
    if (i == 1) {
      ret += solve(i - 1, 1);
      ret %= mod;
    } else {
      ret += solve(i - 1, 1);
      ret %= mod;
      ret += 1 + solve(i - 1, ok);
      ret %= mod;
    }
  }
  return ret;
}
long long bigmod(long long b, long long p, long long m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    long long temp = bigmod(b, p / 2, m);
    return (temp * temp) % m;
  }
  return (bigmod(b, p - 1, m) * (b % m)) % m;
}
int main() {
  memset(memo, -1, sizeof(memo));
  for (int i = 1; i <= maxx; i++) {
    for (int j = i; j <= maxx; j += i) {
      fact[j].push_back(i);
    }
  }
  for (int i = 1; i <= maxx; i++) {
    sort(fact[i].begin(), fact[i].end());
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    pre[a[i]]++;
  }
  for (int i = 1; i <= maxx; i++) {
    pre[i] += pre[i - 1];
  }
  sort(a, a + n);
  long long ans = 1;
  for (int i = maxx; i > 1; i--) {
    long long res = 1;
    long long same = pre[maxx] - pre[i - 1];
    if (same == 0) continue;
    long long len = fact[i].size();
    long long temp = bigmod(len, same, mod);
    long long temp2 = bigmod(len - 1, same, mod);
    temp = temp - temp2;
    temp %= mod;
    temp += mod;
    temp %= mod;
    if (temp > 0) {
      res = res * (temp);
      res %= mod;
    }
    for (long long j = len - 2; j >= 0; j--) {
      long long R = fact[i][j];
      long long R2 = fact[i][j + 1] - 1;
      long long C = pre[R2] - pre[R - 1];
      if (C == 0) continue;
      C = bigmod((j + 1), C, mod);
      C %= mod;
      res = res * C;
      res %= mod;
    }
    ans += res;
    ans %= mod;
  }
  cout << ans << endl;
}
