#include <bits/stdc++.h>
using namespace std;
int cn, T, n, a[100005], divisors1[100005], greaterORequal[100005];
list<int> divisors2;
long long modpow(int x, int y) {
  if (!y) return 1;
  long long os = modpow(x, y >> 1);
  os = os * os % 1000000007;
  return (y & 1) ? x * os % 1000000007 : os;
}
int main() {
  cin.tie(NULL);
  scanf("%d", &n);
  for (auto i = 0; i <= n - 1; i += 1) scanf("%d", &a[i]);
  sort(a, a + n, greater<int>());
  a[n] = 0;
  for (auto i = 0; i <= n - 1; i += 1) {
    for (auto j = a[i]; j >= a[i + 1]; j -= 1) greaterORequal[j] = i + 1;
  }
  int res = 0;
  for (auto i = a[0]; i >= 1; i -= 1) {
    0;
    int cnt = greaterORequal[i], cntd = 0;
    divisors2.clear();
    long long os2 = 1;
    for (auto j = 1; j <= i; j += 1) {
      if (j * 1ll * j > i) break;
      if (!(i % j)) {
        divisors1[cntd++] = (j);
        if (j * 1ll * j != i) divisors2.push_front(i / j);
      }
    }
    for (auto &j : divisors2) divisors1[cntd++] = (j);
    for (auto j = 1; j <= cntd - 1; j += 1) {
      os2 = os2 *
            modpow(j, greaterORequal[divisors1[j - 1]] -
                          greaterORequal[divisors1[j]]) %
            1000000007;
      0, 0;
    }
    long long niye = modpow(cntd, cnt) - modpow(cntd - 1, cnt);
    if (niye >= 1000000007)
      niye -= 1000000007;
    else if (niye < 0)
      niye += 1000000007;
    ;
    os2 = os2 * niye % 1000000007;
    0, 0;
    res += os2;
    if (res >= 1000000007)
      res -= 1000000007;
    else if (res < 0)
      res += 1000000007;
    ;
  }
  printf("%d\n", res);
  return 0;
}
