#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int upto[100010];
int cache[129][100010];
vector<int> cdivs(int n) {
  vector<int> d;
  int i;
  for (i = 1; i * i < n; i++) {
    if (n % i == 0) {
      d.push_back(i);
      d.push_back(n / i);
    }
  }
  if (i * i == n) d.push_back(i);
  sort(d.begin(), d.end());
  return d;
}
long long mpow(int r, int n) {
  if (cache[r][n] != -1) return cache[r][n];
  int n2 = n / 2;
  cache[r][n] = (mpow(r, n2) * mpow(r, n - n2)) % MOD;
  return cache[r][n];
}
int main() {
  vector<int> a;
  int x, n;
  cin >> n;
  for (int i = 1; i <= 128; i++) {
    cache[i][0] = 1;
    cache[i][1] = i;
    for (int j = 2; j <= 100000; j++) cache[i][j] = -1;
  }
  for (int i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int mx = a[n - 1], up = 1, cur = a[0], curi = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == cur) continue;
    for (; up <= cur; up++) upto[up] = n - curi;
    cur = a[i];
    curi = i;
  }
  for (; up <= cur; up++) upto[up] = a.size() - curi;
  vector<int> d;
  long long res = 1;
  for (int m = 2; m <= mx; m++) {
    long long r = 1, sb = 1;
    d = cdivs(m);
    r = (MOD + mpow(d.size(), upto[d[d.size() - 1]]) -
         mpow(d.size() - 1, upto[d[d.size() - 1]])) %
        MOD;
    for (int i = 1; i < d.size() - 1; i++)
      r = (r * mpow(i + 1, upto[d[i]] - upto[d[i + 1]])) % MOD;
    res = (res + r) % MOD;
  }
  cout << res << endl;
  return 0;
}
