#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
long long a[N], n, mx, cnt;
vector<int> v, e;
long long ans = 1;
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  long long res = pw(a, b / 2);
  res = res * res % mod;
  if (b % 2) res = res * a % mod;
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]), mx = max(mx, a[i]);
  sort(a, a + n);
  for (int i = 2; i <= mx; i++) {
    v.clear();
    e.clear();
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        v.push_back(j);
        if (j * j != i) e.push_back(i / j);
      }
    }
    for (int j = (int)e.size() - 1; j >= 0; j--) v.push_back(e[j]);
    int now = 0;
    long long sum = 1, sum2 = 1;
    for (int j = 1; j < (int)v.size(); j++) {
      int to = lower_bound(a + now, a + n, v[j]) - a;
      sum = sum * pw(j, to - now) % mod;
      now = to;
    }
    sum = sum * pw((int)v.size(), n - now) % mod;
    now = 0;
    for (int j = 1; j < v.size() - 1; j++) {
      int to = lower_bound(a + now, a + n, v[j]) - a;
      sum2 = sum2 * pw(j, to - now) % mod;
      now = to;
    }
    sum2 = sum2 * pw((int)v.size() - 1, n - now) % mod;
    ans = (ans + sum) % mod;
    ans = (ans + mod - sum2) % mod;
  }
  ans = (ans + mod) % mod;
  printf("%lld\n", ans);
  return 0;
}
