#include <bits/stdc++.h>
using namespace std;
int q[100005], n;
int w[100005], cnt;
long long ret;
long long Pow(long long a, int k) {
  long long c = 1 % 1000000007;
  while (k) {
    if (k & 1) c = c * a % 1000000007;
    a = a * a % 1000000007;
    k >>= 1;
  }
  return c;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> q[i];
    mx = max(mx, q[i]);
  }
  sort(q, q + n);
  for (int i = 1; i <= mx; i++) {
    cnt = 0;
    long long tmp;
    for (int j = 1; j * j <= i; j++)
      if (i % j == 0) w[cnt++] = j, w[cnt++] = i / j;
    sort(w, w + cnt);
    cnt = unique(w, w + cnt) - w;
    int k0 = lower_bound(q, q + n, i) - q, k1;
    tmp = Pow(cnt, n - k0) - Pow(cnt - 1, n - k0);
    if (tmp < 0) tmp += 1000000007;
    for (int j = cnt - 2; j >= 0; j--) {
      k1 = lower_bound(q, q + n, w[j]) - q;
      tmp = tmp * Pow(j + 1, k0 - k1) % 1000000007;
      k0 = k1;
    }
    ret += tmp;
    if (ret >= 1000000007) ret %= 1000000007;
  }
  cout << ret << endl;
}
