#include <bits/stdc++.h>
long long int n, a[100514];
long long int bs[100514];
long long int mod = 1000000007;
int cmp(long long int a, long long int b) { return a > b; }
void shuru() {
  scanf("%I64d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d", a + i);
  std::sort(a, a + n, cmp);
}
long long int mul(long long int a, long long int x) {
  long long int ans = 1, t = a;
  for (; x; x /= 2) {
    if (x % 2) ans = ans * t % mod;
    t = t * t % mod;
  }
  return ans;
}
long long int fac[10240], ft;
long long int st[10240], top;
long long int ans;
void truli() {
  ans = 0;
  for (long long int j = 100000, i = 0; j >= 1; j--) {
    for (; i < n && a[i] >= j; i++)
      ;
    bs[j] = i;
  }
  for (long long int j = 100000; j >= 1; j--) {
    if (bs[j] == 0) continue;
    top = ft = 0;
    for (long long int k = 1; k * k <= j; k++) {
      if (j % k) continue;
      fac[ft++] = j / k;
      if (k * k == j) continue;
      st[top++] = k;
    }
    for (; top;) fac[ft++] = st[--top];
    long long int tans = (mul(ft, bs[j]) - mul(ft - 1, bs[j]) + mod) % mod;
    for (long long int k = 1, l = bs[j]; k < ft; k++) {
      long long int t = bs[fac[k]];
      tans = tans * mul(ft - k, t - l) % mod;
      l = t;
    }
    ans = (ans + tans) % mod;
  }
  printf("%I64d\n", ans);
}
int main() {
  shuru();
  truli();
  return 0;
}
