#include <bits/stdc++.h>
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
const int MAXN = 1e5 + 7;
const int MOD = (int)1e9 + 7;
int ksm(int a, int b) {
  int ret = 1;
  for (; b; b >>= 1, a = 1ll * a * a % MOD)
    if (b & 1) ret = 1ll * ret * a % MOD;
  return ret;
}
int n, A[MAXN];
vector<int> f[MAXN];
void solve() {
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), A[x]++;
  for (int i = 1; i < MAXN; i++) A[i] += A[i - 1];
  for (int i = 1; i < MAXN; i++)
    for (int j = i; j < MAXN; j += i) f[j].push_back(i);
  int ret = 1;
  for (int i = 2; i < MAXN; i++) {
    int cont = 1;
    for (int j = 1; j < (int)f[i].size(); j++)
      cont = 1ll * cont * ksm(j, A[f[i][j] - 1] - A[f[i][j - 1] - 1]) % MOD;
    int num = A[MAXN - 1] - A[f[i].back() - 1];
    ret = (ret +
           1ll * cont * (ksm(f[i].size(), num) - ksm(f[i].size() - 1, num))) %
          MOD;
  }
  cout << (ret + MOD) % MOD << endl;
}
int main() {
  solve();
  return 0;
}
