#include <bits/stdc++.h>
using namespace std;
double const eps = 1e-6;
const int inf = 0x3fffffff;
const int size = 100000 + 5;
const int mod = 1e9 + 7;
int a[size];
vector<int> fac;
int n;
long long qpow(long long a, int b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  while (ans < 0)
    ;
  return ans;
}
long long cal(int m) {
  fac.clear();
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      fac.push_back(i);
      if (i * i != m) fac.push_back(m / i);
    }
  }
  sort(fac.begin(), fac.end());
  int sz = fac.size();
  int cur = 0, pre = 0;
  long long ret = 1;
  for (int i = 0; i < sz; i++) {
    cur = lower_bound(a, a + n, fac[i]) - a;
    ret = ret * qpow(i, cur - pre) % mod;
    pre = cur;
  }
  assert(ret >= 0);
  ret = ret * (qpow(sz, n - pre) - qpow(sz - 1, n - pre) + mod) % mod;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  long long ans = 0;
  for (int k = 1; k <= a[n - 1]; k++) {
    ans = (ans + cal(k)) % mod;
  }
  printf("%d\n", (int)ans);
  return 0;
}
