#include <bits/stdc++.h>
using namespace std;
int a[100001], pre[100001];
vector<int> vid;
vector<pair<int, int> > fac;
void taj(int n) {
  int cn = n;
  fac.clear();
  for (int i = 2; i * i <= cn; ++i) {
    int cnt = 0;
    while (n % i == 0) {
      ++cnt;
      n /= i;
    }
    if (cnt) fac.push_back(pair<int, int>(i, cnt));
  }
  if (n != 1) fac.push_back(pair<int, int>(n, 1));
}
void mag(int p, int now) {
  if (p == fac.size())
    vid.push_back(now);
  else {
    int POW = 1;
    for (int i = 0; i <= fac[p].second; ++i) {
      mag(p + 1, now * POW);
      POW *= fac[p].first;
    }
  }
}
void do_did_done(int n) {
  taj(n);
  vid.clear();
  mag(0, 1);
  sort(vid.begin(), vid.end());
}
long long pow(int a, int b) {
  if (b == 0) return 1;
  long long t = pow(a, b / 2);
  t = t * t % 1000000007;
  if (b & 1)
    return t * a % 1000000007;
  else
    return t;
}
int main() {
  int n, mx = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  sort(a, a + n);
  pre[0] = 0;
  for (int i = 0, L = 0; i < 100001; ++i) {
    pre[i] = pre[i - 1];
    while (L < n && i == a[L]) pre[i]++, L++;
  }
  int ans = 0;
  for (int i = 1; i <= mx; ++i) {
    do_did_done(i);
    int nod = vid.size();
    int nan =
        (pow(nod, n - pre[i - 1]) - pow(nod - 1, n - pre[i - 1]) + 1000000007) %
        1000000007;
    for (int j = vid.size() - 1; j > 0; --j) {
      nan = ((long long)nan * pow(j, pre[vid[j] - 1] - pre[vid[j - 1] - 1])) %
            1000000007;
    }
    ans = (ans + nan) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
