#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int MOD = (int)1e9 + 7;
int a[N], b[N], c[N], cnt[N], mx = 0;
int pow(int a, int n) {
  long long r = 1, x = a;
  while (n) {
    if (n & 1) r = r * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return (int)r;
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    mx = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), mx = max(mx, a[i]);
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) ++cnt[a[i]];
    for (int i = 1; i <= mx; i++) cnt[i] += cnt[i - 1];
    long long ans = 0;
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= mx; i++) {
      int ct = 0, u = (int)sqrt(i);
      for (int j = 1; j <= u; j++) {
        if (i % j == 0) {
          b[ct++] = j;
          if (j * j != i) b[ct++] = i / j;
        }
      }
      sort(b, b + ct);
      for (int j = 0; j < ct - 1; j++) c[j] = cnt[b[j + 1] - 1] - cnt[b[j] - 1];
      c[ct - 1] = n - cnt[b[ct - 1] - 1];
      long long tmp = 1;
      for (int j = 0; j < ct - 1; j++) {
        tmp *= pow(j + 1, c[j]);
        tmp %= MOD;
      }
      tmp *= ((pow(ct, c[ct - 1]) - pow(ct - 1, c[ct - 1])) + MOD) % MOD;
      tmp %= MOD;
      ans += tmp;
      ans %= MOD;
    }
    printf("%d\n", (int)ans);
  }
  return 0;
}
