#include <bits/stdc++.h>
const int MD = 1000000007;
std::vector<int> f[111111];
int a[111111], g[111111], p[111111];
int n;
int power(int a, int b) {
  int t = 1;
  for (; b; b >>= 1) {
    if (b & 1) t = (long long)t * a % MD;
    a = (long long)a * a % MD;
  }
  return t;
}
int main() {
  int i, j, m, s = 0, t;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%d", a + i);
  std::sort(a, a + n), a[n] = 2147483647;
  for (i = 1; i <= 100000; ++i)
    for (j = i; j <= 100000; j += i) f[j].push_back(i);
  for (i = 1; i <= 100000; ++i) g[i] = f[i].size();
  j = p[0] = 0;
  for (i = 1; i <= 100000; p[i++] = j)
    while (a[j] < i) ++j;
  for (m = 1; m <= 100000; ++m) {
    for (t = 1, i = 0; i < g[m] - 1; ++i)
      t = (long long)t * power(i + 1, p[f[m][i + 1]] - p[f[m][i]]) % MD;
    t = (long long)t *
        (power(g[m], n - p[m]) + MD - power(g[m] - 1, n - p[m])) % MD;
    if ((s += t) >= MD) s -= MD;
  }
  printf("%d", s);
  return 0;
}
