#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
void Dzielniki(int x, vector<int>& d) {
  for (int i = 1; i * i <= x; ++i) {
    if (x % i == 0) d.push_back(i);
    if (x % (x / i) == 0 && i * i != x) d.push_back(x / i);
  }
}
int Szukaj1(vector<int>& a, int x) {
  int l = 0, p = a.size() - 1, s, r = -1;
  while (l <= p) {
    s = (l + p) / 2;
    if (a[s] >= x) {
      r = s;
      p = s - 1;
    } else
      l = s + 1;
  }
  return r;
}
int Szukaj2(vector<int>& a, int x) {
  int l = 0, p = a.size() - 1, s, r = -1;
  while (l <= p) {
    s = (l + p) / 2;
    if (a[s] <= x) {
      r = s;
      l = s + 1;
    } else
      p = s - 1;
  }
  return r;
}
long long Pot(long long a, long long wyk) {
  if (wyk == 1) return a;
  if (wyk % 2 == 1) return a * Pot(a, wyk - 1) % MOD;
  long long x = Pot(a, wyk / 2);
  return x * x % MOD;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  long long odp = 0;
  for (int i = 1; i <= a[n - 1]; ++i) {
    vector<int> d;
    Dzielniki(i, d);
    sort(d.begin(), d.end());
    d.push_back(a[n - 1] + 1);
    long long il = 1;
    for (int j = 0; j < (int)d.size() - 1; ++j) {
      int L = Szukaj1(a, d[j]);
      int P = Szukaj2(a, d[j + 1] - 1);
      if (L <= P && L != -1 && P != -1 && a[L] >= d[j] && a[P] < d[j + 1]) {
        long long w = P - L + 1;
        long long roz = Pot(j + 1, w);
        if (j < (int)d.size() - 2)
          il = (il * roz) % MOD;
        else {
          long long roz_bez = Pot(j, w);
          long long r = roz - roz_bez;
          if (r < 0) r += MOD;
          il = (il * r) % MOD;
        }
      }
    }
    odp = (odp + il) % MOD;
  }
  cout << odp;
  return 0;
}
