#include <bits/stdc++.h>
using std::vector;
vector<int> myinsu[100001];
int ipo(int n, int m) {
  int i, r = 1;
  if (n == 0) return 0;
  if (m == 0) return 1;
  r = ipo(n, m / 2);
  r = (1LL * r * r) % 1000000007;
  if (m % 2) r = (1LL * r * n) % 1000000007;
  return r;
}
int main() {
  int i, j, jid, k, N, ary[100001], insu, res[100001];
  for (i = 1; i <= 100000; i++)
    for (j = 1; i * j <= 100000; j++) myinsu[i * j].push_back(i);
  while (~scanf("%d", &N)) {
    for (i = 0; i < N; i++) scanf("%d", ary + i);
    std::sort(ary, ary + N);
    int ans = 0, t, lastp, rp, tim, pim;
    for (k = ary[N - 1]; k >= 1; k--) {
      insu = myinsu[k].size();
      t = 1;
      lastp = N;
      for (jid = insu - 1; jid >= 0; jid--) {
        j = myinsu[k][jid];
        rp = std::lower_bound(ary, ary + N, j) - ary;
        pim = jid + 1;
        tim = lastp - rp;
        lastp = rp;
        t = (1LL * t * ipo(pim, tim)) % 1000000007;
        if (jid == insu - 1) {
          t = (1LL * t - ipo(pim - 1, tim) + 1000000007) % 1000000007;
        }
      }
      res[k] = t;
    }
    ans = 0;
    for (k = 1; k <= ary[N - 1]; k++) {
      ans = (1LL * ans + res[k]) % 1000000007;
    }
    printf("%d\n", ans);
  }
}
