#include <bits/stdc++.h>
using namespace std;
long long a[2000001], k, ret, sh[10001], mod, i, j, w, n;
long long quick(long long a1, long long b) {
  long long ans;
  ans = 1;
  while (b > 0) {
    if (b & 1 == 1) ans = (ans % mod) * (a1 % mod) % mod;
    a1 = (a1 % mod) * (a1 % mod);
    b /= 2;
  }
  return ans;
}
int main() {
  mod = 1e9 + 7;
  ret = 0;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + 1 + n);
  for (i = a[n]; i >= 1; i--) {
    w = 0;
    k = 1;
    for (j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        w++;
        sh[w] = j;
        if (j != i / j) {
          w++;
          sh[w] = i / j;
        }
      }
    }
    sort(sh + 1, sh + 1 + w);
    long long l, r;
    r = 1;
    l = 1;
    for (j = 1; j < w; j++) {
      l = lower_bound(a + 1, a + 1 + n, sh[j]) - a;
      r = lower_bound(a + 1, a + 1 + n, sh[j + 1]) - a;
      k = (k % mod) * (quick(j, r - l) % mod) % mod;
    }
    k = (k % mod) *
        ((quick(w, n - r + 1) - quick(w - 1, n - r + 1) + mod) % mod) % mod;
    ret += k;
    ret %= mod;
  }
  printf("%lld\n", ret);
}
