#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const int MAX = 1e5 + 1;
using namespace std;
long long cnt[MAX];
vector<long long> factors(long long n) {
  vector<long long> tmp;
  tmp.push_back(1);
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      tmp.push_back(i);
      if (n / i != i) tmp.push_back(n / i);
    }
  }
  sort(tmp.begin(), tmp.end());
  return tmp;
}
long long pow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res % MOD * a % MOD) % MOD;
    }
    a = (a % MOD * a % MOD) % MOD;
    b = b >> 1;
  }
  return res % MOD;
}
int main() {
  int n;
  long long m = INT_MIN, c = 0;
  cin >> n;
  vector<long long> a(n);
  for (auto& c : a) {
    cin >> c;
    m = max(m, c);
  }
  sort(a.begin(), a.end());
  cnt[0] = 0;
  bool flag = false;
  for (int i = 1; i <= m; i++) {
    if (flag) {
      cnt[i] = cnt[i - 1];
      continue;
    }
    auto it = upper_bound(a.begin(), a.end(), i);
    if (it == a.end()) {
      flag = true;
      cnt[i] = a.size();
      continue;
    }
    cnt[i] = it - a.begin();
  }
  for (int i = 1; i <= m; i++) {
    vector<long long> f = factors(i);
    long long s = f.size(), k1;
    if (i == 1)
      k1 = 1;
    else
      k1 = (pow(s + 1, 1ll * (cnt[m] - cnt[i - 1])) -
            pow(s, 1ll * (cnt[m] - cnt[i - 1])) + MOD) %
           MOD;
    f.push_back(i);
    long long k2 = 1;
    for (int j = 1; j <= s; j++) {
      k2 *= pow(j * 1ll, 1ll * (cnt[f[j] - 1] - cnt[f[j - 1] - 1])) % MOD;
      k2 %= MOD;
    }
    c = (c % MOD + (k1 % MOD * k2 % MOD) % MOD) % MOD;
  }
  cout << c;
}
