#include <bits/stdc++.h>
using namespace std;
int N;
long long Ans, MOD = 1000000007;
int mx;
int num[200000];
vector<int> v[200000];
int q[200000], r[200000];
int bs(int p) {
  int l = -1, r = N, mid;
  while (l + 1 != r) {
    mid = (l + r) / 2;
    if (num[mid] >= p)
      r = mid;
    else
      l = mid;
  }
  return N - r;
}
long long pwd(int x, int n) {
  if (n == 0) return 1;
  long long p = pwd(x, n / 2);
  if (n & 1) {
    return ((p * p % MOD) * x) % MOD;
  } else
    return (p * p % MOD);
}
int main() {
  for (int i = 1; i <= 100000; i++) {
    for (int j = i; j <= 100000; j += i) {
      v[j].push_back(i);
    }
  }
  scanf("%d", &N);
  for (int Ni = 0; Ni < N; Ni++) {
    scanf("%d", &num[Ni]);
    mx = max(num[Ni], mx);
  }
  sort(num, num + N);
  for (int i = 1; i <= mx; i++) {
    q[v[i].size()] = 0;
    for (int vi = 0, vn = v[i].size(); vi < vn; vi++) q[vi] = bs(v[i][vi]);
    for (int vi = 0, vn = v[i].size(); vi < vn; vi++) {
      r[vi] = q[vi] - q[vi + 1];
    }
    long long p = 1;
    for (int vi = 0, vn = v[i].size(); vi < vn; vi++) {
      if (vi + 1 == vn) {
        p *= (pwd(vi + 1, r[vi]) - pwd(vi, r[vi]));
        p %= MOD;
      } else
        p *= pwd(vi + 1, r[vi]);
      p %= MOD;
    }
    Ans += p;
    Ans %= MOD;
  }
  printf("%I64d\n", (Ans % MOD + MOD) % MOD);
}
