#include <bits/stdc++.h>
using namespace std;
const int N = 1e5, mod = 1e9 + 7;
vector<int> d[N + 10];
int a[N + 10];
long long power(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return (a % mod);
  long long ret = power(a, b / 2);
  ret *= ret;
  ret %= mod;
  if (b % 2 == 1) ret *= a;
  ret %= mod;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int maxi = a[n - 1];
  a[n] = N + 100;
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) d[j].push_back(i);
    d[i].push_back(N + 10);
  }
  long long Ans = 1;
  for (int m = 2; m <= maxi; m++) {
    int sz = d[m].size();
    long long ans1 = 1, ans2 = 1;
    for (int i = 0; i < sz - 1; i++) {
      int ind1 = lower_bound(a, a + n, d[m][i]) - a;
      int ind2 = lower_bound(a, a + n, d[m][i + 1]) - a;
      int cnt = ind2 - ind1;
      int state = i + 1;
      ans1 *= power(state, cnt);
      ans1 %= mod;
    }
    d[m][sz - 2] = N + 10;
    for (int i = 0; i < sz - 2; i++) {
      int ind1 = lower_bound(a, a + n, d[m][i]) - a;
      int ind2 = lower_bound(a, a + n, d[m][i + 1]) - a;
      int cnt = ind2 - ind1;
      int state = i + 1;
      ans2 *= power(state, cnt);
      ans2 %= mod;
    }
    Ans += ans1 + mod - ans2;
    Ans %= mod;
  }
  cout << Ans << '\n';
}
