#include <bits/stdc++.h>
using namespace std;
long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
const long long maxn = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 10;
long long atleast[maxn], a[maxn];
long long n;
long long res;
inline long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b % 2) ret = ret * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ret;
}
int32_t main() {
  n = in();
  for (long long i = 0; i < n; i++) a[i] = in();
  sort(a, a + n);
  long long cur = n;
  for (long long i = maxn - 1; i >= 0; i--) {
    while (cur > 0 && a[cur - 1] >= i) cur--;
    atleast[i] = n - cur;
  }
  for (long long lcm = 1; lcm <= a[n - 1]; lcm++) {
    vector<long long> divisors;
    for (long long q = 1; q * q <= lcm; q++) {
      if (lcm % q) continue;
      long long q2 = lcm / q;
      divisors.push_back(q);
      if (q - q2) divisors.push_back(q2);
    }
    sort(divisors.begin(), divisors.end());
    divisors.push_back(a[n - 1] + 1);
    long long add = 1;
    for (long long i = 0; i + 1 < divisors.size(); i++) {
      long long cnt = atleast[divisors[i]] - atleast[divisors[i + 1]];
      long long mull = ((power(i + 1, cnt)) -
                        (i + 2 == divisors.size() ? power(i, cnt) : 0) + mod) %
                       mod;
      add = add * mull % mod;
    }
    res = (res + add) % mod;
  }
  cout << res << endl;
}
