#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long pow_mod(long long base, long long power) {
  long long res = 1;
  while (power) {
    if (power & 1) res = res * base % mod;
    base = base * base % mod;
    power >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long res = 0;
  for (long long lcm = 1; lcm <= a.back(); lcm++) {
    vector<long long> dvs;
    for (long long i = 1; i * i <= lcm; i++) {
      if (lcm % i) continue;
      dvs.push_back(i);
      if (i * i < lcm) dvs.push_back(lcm / i);
    }
    sort(dvs.begin(), dvs.end());
    long long cur = 1;
    int last = a.size();
    for (int i = dvs.size() - 1; i >= 0; i--) {
      long long dv = dvs[i];
      auto it = lower_bound(a.begin(), a.end(), dv) - a.begin();
      int nums = last - it;
      cur = cur * pow_mod(i + 1, nums) % mod;
      if (last == a.size()) cur = (cur + mod - pow_mod(i, nums)) % mod;
      last = it;
    }
    res = (res + cur) % mod;
  }
  cout << res << '\n';
  return 0;
}
