#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
const int MAXN = 100010;
const long long MOD = 1e9 + 7;
int sum[MAXN];
int src[MAXN], N, num;
int val[MAXN], cnt[MAXN];
long long pow_mod(long long x, long long cnt) {
  long long ret = 1;
  while (cnt) {
    if (cnt & 1LL) ret = ret * x % MOD;
    x = x * x % MOD;
    cnt >>= 1LL;
  }
  return ret;
}
int main() {
  while (scanf("%d", &N) != EOF) {
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= N; i++) scanf("%d", &src[i]);
    for (int i = 1; i <= N; i++) cnt[src[i]]++;
    sort(src + 1, src + 1 + N);
    memset(sum, 0, sizeof(sum));
    sum[src[N]] = cnt[src[N]];
    for (int i = src[N] - 1; i >= 1; i--) sum[i] = sum[i + 1] + cnt[i];
    long long ans = 1;
    for (int i = 2; i <= src[N]; i++) {
      num = 0;
      for (int j = 1; j * j <= i; j++) {
        if (j * j == i)
          val[num++] = j;
        else if (i % j == 0) {
          val[num++] = j;
          val[num++] = i / j;
        }
      }
      sort(val, val + num);
      long long res = (long long)sum[val[num - 1]];
      long long ret = (pow_mod((long long)num, res) -
                       pow_mod((long long)(num - 1), res) + MOD) %
                      MOD;
      for (int j = 0; j < num - 1; j++) {
        res = (long long)sum[val[j]] - sum[val[j + 1]];
        ret = (ret * pow_mod((long long)(j + 1), res)) % MOD;
      }
      ans = (ans + ret) % MOD;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
