#include <bits/stdc++.h>
using namespace std;
const double EPS = -1e8;
const double Pi = acos(-1);
bool inline equ(double a, double b) { return fabs(a - b) < EPS; }
const int MAXN = 100010;
const long long MOD = 1000000007ll;
inline long long add(long long a, long long b) { return (a + b) % MOD; }
inline long long mul(long long a, long long b) { return (a * b) % MOD; }
inline long long sub(long long a, long long b) { return (a - b + MOD) % MOD; }
inline long long pw(long long a, long long b) {
  long long res = 1ll, bs = a;
  while (b) {
    if (b & 1) res = mul(res, bs);
    bs = mul(bs, bs);
    b >>= 1;
  }
  return res;
}
int n, in[MAXN];
vector<int> fac[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d", in + i);
  sort(in + 1, in + 1 + n, greater<int>());
  int mx = in[1];
  for (int i = (1); i <= (mx); i++)
    for (int j = i; j <= mx; j += i) fac[j].push_back(i);
  long long ans = 1ll;
  for (int i = (2); i <= (mx); i++) {
    int prv = 1;
    long long tmp = 1ll;
    for (int j = ((int)(fac[i]).size() - 1); j >= (0); j--) {
      int now = upper_bound(in + 1, in + 1 + n, fac[i][j], greater<int>()) - in;
      tmp = mul(tmp, pw(j + 1, now - prv));
      prv = now;
    }
    long long tmp2 = 1ll;
    prv = 1;
    for (int j = ((int)(fac[i]).size() - 2); j >= (0); j--) {
      int now = upper_bound(in + 1, in + 1 + n, fac[i][j], greater<int>()) - in;
      tmp2 = mul(tmp2, pw(j + 1, now - prv));
      prv = now;
    }
    ans = add(ans, sub(tmp, tmp2));
  }
  cout << ans << '\n';
}
