#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  if (a >= mod) a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    if (res >= mod) res %= mod;
    a = a * a;
    if (a >= mod) a %= mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int coun[100000 + 5];
vector<int> v[100000 + 5];
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin.tie(0);
  cout.tie(0);
  int n, i, j, x;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    coun[x]++;
  }
  for (i = 100000; i >= 0; i--) coun[i] += coun[i + 1];
  for (i = 1; i <= 100000; i++)
    for (j = 1; i * j <= 100000; j++) v[i * j].push_back(i);
  long long ans = 0, temp, tans = 1, val;
  for (i = 100000; i; i--) {
    temp = coun[i];
    if (temp == 0) continue;
    tans = powmod(v[i].size(), temp) - powmod(v[i].size() - 1, temp);
    if (tans < 0) tans += mod;
    for (j = v[i].size() - 2; j >= 0; j--) {
      val = coun[v[i][j]] - coun[v[i][j + 1]];
      tans = tans * powmod(j + 1, val);
      if (tans >= mod) tans %= mod;
    }
    ans += tans;
    if (ans >= mod) ans -= mod;
  }
  cout << ans << '\n';
  return 0;
}
