#include <bits/stdc++.h>
using namespace std;
int cnt[100100];
int R[100100];
int n;
long long power(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;
}
int main() {
  memset(cnt, 0, sizeof(cnt));
  scanf("%d", &n);
  int maxA = 0;
  for (int i = 1; i <= n; i++) {
    int tmp;
    scanf("%d", &tmp);
    cnt[tmp]++;
    maxA = max(maxA, tmp);
  }
  for (int i = maxA; i >= 1; i--) cnt[i] += cnt[i + 1];
  long long ans = 0;
  for (int i = 1; i <= maxA; i++) {
    int tot = 0;
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        R[tot++] = j;
        if (j * j != i) {
          R[tot++] = i / j;
        }
      }
    }
    sort(R, R + tot);
    long long tmp =
        (power(tot, cnt[R[tot - 1]]) -
         power(tot - 1, cnt[R[tot - 1]]) % 1000000007 + 1000000007) %
        1000000007;
    for (int j = 0; j < tot - 1; j++)
      tmp = (tmp * power(j + 1, cnt[R[j]] - cnt[R[j + 1]])) % 1000000007;
    ans = (ans + tmp) % 1000000007;
  }
  printf("%I64d\n", ans);
  return 0;
}
