#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long N = 1e5 + 5;
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long pow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b >>= 1;
  }
  return res;
}
vector<long long> cnt(N, 0);
signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  vector<long long> v(1e5 + 5, 1);
  for (long long i = 2; i < 1e5 + 5; i++) {
    if (v[i] == 1) {
      v[i] = i;
      for (long long j = i * i; j < 1e5 + 5; j += i) v[j] = i;
    }
  }
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long mx = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    mx = max(mx, a[i]);
  }
  for (long long i = 1; i < 1e5 + 2; i++) {
    cnt[i] += cnt[i - 1];
  }
  long long ans = 0;
  sort((a).begin(), (a).end());
  for (long long i = 1; i < mx + 1; i++) {
    long long x = sqrt(i);
    long long val = 1;
    vector<long long> div;
    for (long long j = 1; j < x + 1; j++) {
      if (i % j == 0) {
        div.push_back(j);
        if (j * j != i) div.push_back(i / j);
      }
    }
    div.push_back(mx + 1);
    sort((div).begin(), (div).end());
    for (long long j = 0; j < (long long)div.size() - 1; j++) {
      if (j == (long long)div.size() - 2) {
        long long c = cnt[div[j + 1] - 1] - cnt[div[j] - 1];
        long long b = powm(j + 1, c) - powm(j, c);
        b = (b + 1000000007) % 1000000007;
        val *= b;
      } else {
        long long c = cnt[div[j + 1] - 1] - cnt[div[j] - 1];
        val *= powm(j + 1, c);
      }
      val %= 1000000007;
    }
    ans += val;
    ans %= 1000000007;
  }
  cout << ans << '\n';
}
