#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int suf[111111], a[111111];
vector<int> g[111111];
int n, m;
long long pow_mod(long long ba, long long ex) {
  long long res = 1;
  while (ex) {
    if (ex & 1) res = (res * ba) % mod;
    ex >>= 1;
    ba = (ba * ba) % mod;
  }
  return res;
}
int main() {
  for (int i = 1; i <= 111100; i++)
    for (int j = i; j <= 111100; j += i) g[j].push_back(i);
  scanf("%d", &n);
  int maxN = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    maxN = max(maxN, a[i]);
    suf[a[i]]++;
  }
  for (int i = maxN; i >= 1; i--) suf[i] = suf[i + 1] + suf[i];
  long long ans = 1;
  for (int i = 2; i <= maxN; i++) {
    int len = 0;
    int st = suf[i];
    len += st;
    long long tAns =
        (pow_mod((long long)g[i].size(), (long long)st) -
         pow_mod((long long)g[i].size() - 1, (long long)st) + mod) %
        mod;
    for (int j = g[i].size() - 2; j >= 0; j--) {
      tAns = (tAns * pow_mod((long long)j + 1, suf[g[i][j]] - len)) % mod;
      len = len + (suf[g[i][j]] - len);
    }
    ans = (ans + tAns) % mod;
  }
  cout << ans << endl;
  return 0;
}
