#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int dziel[N];
int A[N];
int B[N];
int n;
const long long P = 1000000000 + 7;
long long pot(long long a, long long wyk) {
  long long res = 1, pom = a;
  while (wyk) {
    if (wyk & 1) res = (res * pom) % P;
    wyk >>= 1;
    pom = (pom * pom) % P;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) scanf("%d", &A[i]);
  sort(A, A + n);
  long long res = 1;
  for (int i = 2; i <= (A[n - 1]); ++i) {
    int ind = 0;
    for (int j = 1; j * j <= i; ++j) {
      if (i % j == 0) {
        B[ind++] = j;
        if (j != (i / j)) B[ind++] = i / j;
      }
    }
    sort(B, B + ind);
    long long pom = 1;
    int p = 0;
    int prev = 0;
    for (int j = 1; j <= (ind - 1); ++j) {
      p = lower_bound(A + prev, A + n, B[j]) - A;
      pom = (pom * pot(j, p - prev)) % P;
      prev = p;
    }
    long long op = (pot(ind, n - p) - pot(ind - 1, n - p) + P) % P;
    pom = (pom * op) % P;
    res = (res + pom) % P;
  }
  cout << res << endl;
  return 0;
}
