#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = (1 << 29) - 1;
const double eqs = 1e-8;
const int N = 100003;
int have[N];
int a[N];
int b[N];
long long pow_mod(long long a, int b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
int main() {
  int n, i, j, k, qmax = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", a + i);
    have[a[i]]++;
    qmax = max(qmax, a[i]);
  }
  for (i = qmax - 1; i >= 0; i--) have[i] += have[i + 1];
  int front = 0, rear = N - 1;
  long long ans = 0;
  for (i = 2; i <= qmax; i++) {
    front = 0, rear = N - 1;
    for (j = 1; j * j <= i; j++)
      if (i % j == 0) {
        b[front++] = j;
        b[rear--] = i / j;
        if (b[front - 1] == b[rear + 1]) rear++;
      }
    while (rear < N - 1) b[front++] = b[++rear];
    long long tmp = 1;
    for (k = front - 1; k >= 0; k--) {
      if (k == front - 1)
        tmp = tmp *
              ((pow_mod(k + 1, have[b[k]]) - pow_mod(k, have[b[k]]) + mod) %
               mod) %
              mod;
      else
        tmp = tmp * pow_mod(k + 1, have[b[k]] - have[b[k + 1]]) % mod;
    }
    ans += tmp;
  }
  ans++;
  cout << ans % mod << endl;
  return 0;
}
