#include <bits/stdc++.h>
using namespace std;
int DEBUG = 0;
int Min(int a, int b) { return (a < b ? a : b); }
int Max(int a, int b) { return (a > b ? a : b); }
int Abs(int a) { return (a >= 0 ? a : -a); }
void print1d(int *vec, int M, const char *str = NULL) {
  if (str != NULL) printf("%s ", str);
  for (int i = 0; i < M; i++) {
    if (i > 0) printf(" ");
    printf("%d", vec[i]);
  }
  printf("\n");
}
int compare_inc(const void *a, const void *b) {
  if (*(int *)a > *(int *)b) return 1;
  if (*(int *)a < *(int *)b) return -1;
  return 0;
}
int binary_search_count_ge_x(int *a, int n, int x) {
  if (x <= a[0]) return n;
  if (a[n - 1] < x) return 0;
  int s = 0, e = n - 1;
  while (s < e) {
    int mid = int((s + e) / 2);
    if (a[mid] >= x) {
      e = mid;
    } else {
      s = mid > s ? mid : (s + 1);
    }
  }
  return (n - e);
}
int64_t powmod(int64_t base, int64_t expo, int64_t mod) {
  if (expo == 0)
    return 1;
  else if (expo & 1)
    return base * powmod(base, expo - 1, mod) % mod;
  else {
    int64_t root = powmod(base, expo >> 1, mod);
    return root * root % mod;
  }
}
int main(int argc, char **argv) {
  DEBUG = (argc >= 2) ? atoi(argv[1]) : 0;
  int n;
  cin >> n;
  int a[n];
  int maxa = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    maxa = Max(maxa, a[i]);
  }
  qsort(a, n, sizeof(int), compare_inc);
  if (DEBUG) {
    for (int i = 0; i < n; i++) cout << " " << a[i];
    printf(" maxa= %d\n", maxa);
  }
  int64_t out = 0;
  for (int maxb = 1; maxb <= maxa; maxb++) {
    int fac[n], fac2[n];
    int nf = 0, nf2 = 0;
    for (int f = 1; f * f <= maxb; f++) {
      if (maxb % f == 0) {
        fac[nf++] = f;
        if (maxb / f != f) fac2[nf2++] = maxb / f;
      }
    }
    for (int i = 0; i < nf2; i++) fac[nf++] = fac2[nf2 - 1 - i];
    if (DEBUG) {
      printf("maxb= %d fac[]:", maxb);
      for (int i = 0; i < nf; i++) printf(" %d", fac[i]);
      printf("\n");
    }
    int cnt_prev = 0;
    int64_t out2 = 1;
    for (int i = nf - 1; i >= 0; i--) {
      int cnt = binary_search_count_ge_x(a, n, fac[i]);
      int64_t out3 = powmod(i + 1, (cnt - cnt_prev), 1000000007);
      if (i == nf - 1) {
        out3 -= powmod(i, (cnt - cnt_prev), 1000000007);
        if (out3 < 0) out3 += 1000000007;
      }
      out2 = (out2 * out3) % 1000000007;
      if (DEBUG) {
        cout << "maxb= " << maxb << " fac= " << fac[i] << " cnt= " << cnt
             << " out2= " << out2 << endl;
      }
      cnt_prev = cnt;
    }
    out = (out + out2) % 1000000007;
    if (DEBUG) {
      cout << "maxb= " << maxb << " out= " << out << endl << endl;
    }
  }
  cout << out << endl;
  return 0;
}
