#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1000 * 1000 * 1000 + 7);
long long a[200000], ans = 1;
bool mark[200000];
vector<long long> k;
long long Pow(int p, int t) {
  if (!t) return 1;
  long long now = Pow(p, t / 2);
  if (t % 2) return ((now * now) % MOD * p) % MOD;
  return (now * now) % MOD;
}
void mElayh(int n) {
  k.clear();
  for (int i = 1; i * i <= n; i++)
    if (n % i == 0) {
      k.push_back(i);
      if (i * i != n) k.push_back(n / i);
    }
  sort(k.begin(), k.end());
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 2; i <= a[n - 1]; i++) {
    long long kans = 1, *now, *last;
    mElayh(i);
    last = a;
    for (int j = 0; j < k.size(); j++) {
      now = lower_bound(a, a + n, k[j]);
      kans = (kans * Pow(j, now - last)) % MOD;
      last = now;
    }
    kans = (kans * (Pow(k.size(), &a[n] - now) -
                    Pow(k.size() - 1, &a[n] - now) + 2 * MOD)) %
           MOD;
    ans = (ans + kans) % MOD;
  }
  cout << ans << endl;
}
