#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int maxn = 100000 + 10;
long long ans;
int n, Max, a[maxn], c[maxn];
void initial() {
  ans = 1;
  Max = -1;
  memset(c, 0, sizeof(c));
}
void input() {
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    c[a[i]]++;
    Max = max(Max, a[i]);
  }
  for (int i = maxn - 2; i >= 1; i--) c[i] += c[i + 1];
}
long long pow_mod(long long num, long long cnt) {
  long long ret = 1, op = num, tp = cnt;
  while (tp) {
    if (tp & 1) ret = (ret * op) % mod;
    tp >>= 1;
    op = op * op % mod;
  }
  return ret % mod;
}
void solve() {
  vector<int> p;
  for (int i = 2; i <= Max; i++) {
    p.clear();
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        p.push_back(j);
        if (j * j != i) p.push_back(i / j);
      }
    }
    sort(p.begin(), p.end());
    int len = p.size();
    long long sum =
        (pow_mod(len, c[p[len - 1]]) - pow_mod(len - 1, c[p[len - 1]]) + mod) %
        mod;
    for (int j = 0; j < len - 1; j++) {
      sum = (sum * pow_mod(j + 1, c[p[j]] - c[p[j + 1]])) % mod;
    }
    ans = (sum + ans) % mod;
  }
  cout << ans << endl;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    initial();
    input();
    solve();
  }
}
