#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
long long fr[200005], a[200005], b[200005];
long long bigmod(long long n, long long p) {
  if (p == 0) return 1;
  long long x = bigmod(n, p / 2);
  x = (x * x) % 1000000007;
  if (p % 2 == 1) x = (x * n) % 1000000007;
  return x;
}
vector<int> adj[200005];
void pre() {
  long long i, j;
  for (i = 1; i <= 100000; i++) {
    for (j = i; j <= 100000; j += i) adj[j].push_back(i);
  }
}
long long cal(long long x) {
  long long i, j;
  long long k = adj[x].size();
  vector<long long> v;
  for (i = 0; i + 1 < adj[x].size(); i++) {
    long long p = fr[adj[x][i + 1] - 1] - fr[adj[x][i] - 1];
    v.push_back(p);
  }
  long long mu = 1;
  for (i = 0; i < v.size(); i++) {
    mu *= bigmod(i + 1, v[i]);
    mu %= 1000000007;
  }
  if (fr[100000] - fr[x - 1] == 0) return 0;
  long long x1 = fr[100000] - fr[x - 1];
  x1 = (bigmod(k, x1) - bigmod(k - 1, x1) + 1000000007) % 1000000007;
  mu = (mu * x1) % 1000000007;
  return mu;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long i, j, u, v, tc, n;
  pre();
  while (cin >> n) {
    for (i = 1; i <= n; i++) {
      cin >> a[i];
      fr[a[i]]++;
    }
    for (i = 1; i <= 100000; i++) fr[i] += fr[i - 1];
    long long ans = 0;
    for (i = 1; i <= 100000; i++) {
      ans += cal(i);
      ans %= 1000000007;
    }
    cout << ans << endl;
  }
  return 0;
}
