#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1e9) + 7;
const long double EPS = 0.0000001;
const int N = 100000 + 5000;
long long csum[N];
vector<int> factorise(int n) {
  vector<int> ans;
  for (int i = 1; i * i <= n; i++) {
    if (n % i) continue;
    ans.push_back(i);
    if ((i * i) != n) ans.push_back(n / i);
  }
  sort(ans.begin(), ans.end());
  ans.push_back(N - 1);
  return ans;
}
long long pows(long long a, long long b) {
  if (b == 0) return 1;
  long long temp = pows(a, b / 2);
  temp = (temp * temp) % MOD;
  if (b % 2) temp = (temp * a) % MOD;
  return temp;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    csum[x]++;
  }
  for (int i = 1; i < N; i++) csum[i] = csum[i - 1] + csum[i];
  long long ans = 0;
  for (int i = 1; i <= 100000; i++) {
    vector<int> factors = factorise(i);
    long long temp = 1;
    for (int j = 0; j < factors.size() - 1; j++) {
      if (j == (factors.size() - 2)) {
        int x = factors[j];
        int y = factors[j + 1];
        long long num = csum[y - 1] - csum[x - 1];
        long long temp2 = (pows(j + 1, num) - pows(j, num) + MOD) % MOD;
        temp = (temp * temp2) % MOD;
      } else {
        int x = factors[j];
        int y = factors[j + 1];
        long long num = csum[y - 1] - csum[x - 1];
        temp = (temp * pows(j + 1, num)) % MOD;
      }
    }
    ans = (ans + temp + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}
