#include <bits/stdc++.h>
using namespace std;
const int maxNum = 100010;
const int MOD = 1000000007;
int cnt[100010], great[100010], a[100010];
long long fp[100010];
long long power(int j, int p) {
  if (j == 0) return 0;
  if (p == 0) return 1;
  long long tmp = power(j, p / 2) % MOD;
  if (p % 2 == 0)
    return (tmp * tmp) % MOD;
  else
    return ((tmp * tmp) % MOD * j) % MOD;
}
long long fact(int k) {
  if (fp[k] != -1)
    return fp[k];
  else
    return fp[k] = (fact(k - 1) * k) % MOD;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    fp[i + 1] = -1;
  }
  fp[0] = fp[1] = 1;
  for (int i = maxNum; i >= 1; i--) great[i] = great[i + 1] + cnt[i];
  long long ans = 0;
  vector<int> divide;
  for (int i = 1; i <= maxNum; i++) {
    divide.clear();
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        divide.push_back(j);
        if (i / j != j) divide.push_back(i / j);
      }
    }
    sort(divide.begin(), divide.end());
    long long tmp =
        (power(divide.size(), great[i]) - power(divide.size() - 1, great[i])) %
        MOD;
    while (tmp < 0) tmp += MOD;
    for (int j = 1; j < divide.size(); j++) {
      tmp *= power(j, (great[divide[j]] - great[divide[j - 1]]));
      tmp %= MOD;
    }
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}
