#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7, mod = 1e9 + 7;
long long c[N], dp[N];
vector<long long> d[N];
long long POW(long long a, long long b, long long mod) {
  a %= mod;
  long long r = 1;
  for (long long i = b; i > 0; i >>= 1) {
    if (i & 1) r = (r * a) % mod;
    a = (a * a) % mod;
  }
  return r;
}
long long f(vector<long long> v) {
  if (c[N - 1] - c[v.back() - 1] == 0) return 0;
  long long ans = 1, mx = N - 1;
  for (long long i = v.size() - 1; i >= 0; i--) {
    ans = ans * POW(i + 1, c[mx - 1] - c[v[i] - 1], mod) % mod;
    mx = v[i];
  }
  return ans;
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    c[x]++;
  }
  for (long long i = 1; i < N; i++) {
    c[i] += c[i - 1];
  }
  for (long long i = 1; i < N; i++) {
    for (long long j = i; j < N; j += i) {
      d[j].push_back(i);
    }
  }
  dp[1] = 1;
  for (long long i = 2; i < N; i++) {
    dp[i] = f(d[i]);
    if (dp[i] == 0) {
      dp[i] = dp[i - 1];
      continue;
    }
    d[i].pop_back();
    dp[i] = (dp[i] + mod - f(d[i])) % mod;
    dp[i] = (dp[i] + dp[i - 1]) % mod;
  }
  cout << dp[N - 1] << endl;
}
