#include <bits/stdc++.h>
int n;
int arr[100000];
int facs[100000 + 1], lf;
int jizz[100000 + 1];
long long pow(int a, int b) {
  long long ans = 1;
  for (long long gg = a; b; b >>= 1) {
    if (b & 1) ans = (ans * gg) % 1000000007;
    gg = (gg * gg) % 1000000007;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
  std::sort(arr, arr + n);
  jizz[1] = n;
  for (int i = 2; i <= arr[n - 1]; ++i)
    for (jizz[i] = jizz[i - 1]; arr[n - jizz[i]] < i; --jizz[i])
      ;
  long long ans = 1;
  for (int i = arr[n - 1]; i > 1; --i) {
    lf = 0;
    for (int j = 1; j * j <= i; ++j) {
      if (i % j != 0) continue;
      facs[lf] = j;
      facs[100000 - lf] = i / j;
      lf += 1;
    }
    for (int lfb = lf, j = lf - (facs[lf - 1] * facs[lf - 1] == i ? 2 : 1);
         j >= 0; --j)
      facs[lf++] = facs[100000 - j];
    long long tmp = (pow(lf, jizz[facs[lf - 1]]) -
                     pow(lf - 1, jizz[facs[lf - 1]]) + 1000000007) %
                    1000000007;
    for (int j = lf - 1; j > 0; --j)
      tmp = (tmp * pow(j, jizz[facs[j - 1]] - jizz[facs[j]])) % 1000000007;
    ans = (ans + tmp) % 1000000007;
  }
  printf("%d\n", (int)(ans));
  return 0;
}
