#include <bits/stdc++.h>
using namespace std;
vector<int> div(int n) {
  vector<int> v;
  v.push_back(1);
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      v.push_back(n / i);
    }
  }
  v.push_back(n);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}
vector<int> v;
const int N = 100000, MOD = 1000000007;
int n, a[N];
int count_poss(int x) { return n - (lower_bound(a, a + n, x) - a); }
long long mod_pow(long long x, int p) {
  long long r = 1;
  x %= MOD;
  while (p) {
    if (p & 1) {
      r *= x;
      r %= MOD;
    }
    x *= x;
    x %= MOD;
    p /= 2;
  }
  return r;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long ans = 0;
  for (int i = 1; i <= a[n - 1]; i++) {
    long long ways = 1;
    v = div(i);
    int old_z = 0;
    for (int j = v.size() - 1; j >= 0; j--) {
      int z = count_poss(v[j]);
      int place = z - old_z;
      long long cnt = mod_pow((j + 1), place);
      if (j + 1 == v.size()) {
        cnt -= mod_pow(j, place);
        cnt = (cnt + MOD) % MOD;
      }
      ways *= cnt;
      ways %= MOD;
      old_z = z;
    }
    ans += ways;
    ans %= MOD;
  }
  cout << ans << endl;
}
