#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e5 + 9, MOD = 1e9 + 7;
vector<long long> shm[MX];
long long a[MX], cnt[MX];
long long POW(long long a, long long b) {
  if (b == 0) return 1;
  long long ans = POW(a, b / 2);
  ans = (ans * ans) % MOD;
  if (b % 2) ans = (ans * a) % MOD;
  return ans;
}
void SIEVE() {
  for (long long i = 1; i < MX; i++)
    for (long long j = i; j < MX; j += i) shm[j].push_back(i);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  SIEVE();
  for (long long i = 0; i < n; i++) cin >> a[i], cnt[a[i]]++;
  for (long long i = 1; i < MX; i++) cnt[i] += cnt[i - 1];
  long long ans = 0;
  for (long long k = 1; k < MX; k++) {
    long long way = 1;
    for (long long i = 1; i < shm[k].size(); i++)
      way = (way * POW(i, cnt[shm[k][i] - 1] - cnt[shm[k][i - 1] - 1])) % MOD;
    way = (way * ((POW(shm[k].size(), cnt[MX - 1] - cnt[k - 1]) -
                   POW(shm[k].size() - 1, cnt[MX - 1] - cnt[k - 1]) + MOD) %
                  MOD)) %
          MOD;
    ans = (ans + way) % MOD;
  }
  cout << ans;
  return 0;
}
