#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
int a[N], sum[N], cnt[N], n;
vector<int> vec;
int qpow(int x, int p) {
  int ret = 1;
  while (p) {
    if (p & 1) ret = ret * 1LL * x % MOD;
    x = x * 1LL * x % MOD;
    p >>= 1;
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  int mx = 0;
  for (int i = 0; i < (n); i++) {
    scanf("%d", a + i);
    cnt[a[i]]++;
    mx = max(mx, a[i]);
  }
  for (int i = 1; i < N; i++) sum[i] = sum[i - 1] + cnt[i];
  int ans = 0;
  for (int i = 1; i <= mx; i++) {
    vec.clear();
    for (int j = 1; j * j <= i; j++) {
      if (i % j) continue;
      vec.push_back(j);
      if (j * j != i) vec.push_back(i / j);
    }
    sort(vec.begin(), vec.end());
    int m = vec.size();
    int cur = 1, tmp;
    for (int j = 0; j < (m - 1); j++) {
      tmp = sum[vec[j + 1] - 1] - sum[vec[j] - 1];
      cur = cur * 1LL * qpow(j + 1, tmp) % MOD;
    }
    tmp = n - sum[vec[m - 1] - 1];
    if (!tmp) continue;
    int f = (qpow(m, tmp) - qpow(m - 1, tmp) + MOD) % MOD;
    cur = cur * 1LL * f % MOD;
    ans = (ans + cur) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}
