#include <bits/stdc++.h>
using namespace std;
template <typename T>
T nextInt() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * p;
}
const int maxN = (int)1e5 + 10;
const int INF = (int)1e9;
const int mod = (int)1e9 + 7;
const long long LLINF = (long long)1e18;
int n;
int a[maxN];
vector<int> divisors[maxN];
int mul(int x, int y) { return (x * 1LL * y) % mod; }
int binpow(int x, int n) {
  int ret = 1;
  while (n) {
    if (n % 2 == 1) ret = mul(ret, x);
    x = mul(x, x);
    n /= 2;
  }
  return ret;
}
int calc[maxN];
int solve(int x) {
  int last = 0;
  int ret = 1;
  for (size_t i = 0; i < divisors[x].size(); ++i) {
    int d = divisors[x][i];
    int up = (i + 1 == divisors[x].size()
                  ? n
                  : lower_bound(a, a + n, divisors[x][i + 1]) - a);
    ret = mul(ret, binpow(i + 1, up - last));
    last = up;
  }
  return ret;
}
int main() {
  for (int i = 1; i < maxN; ++i) {
    for (int j = i; j < maxN; j += i) {
      divisors[j].push_back(i);
    }
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int res = 1;
  for (int i = 2; i <= a[n - 1]; ++i) {
    res += solve(i);
    if (res >= mod) res -= mod;
    divisors[i].pop_back();
    res -= solve(i);
    if (res < 0) res += mod;
  }
  cout << res << '\n';
  return 0;
}
