#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int MOD = 1e9 + 7;
int a[maxn];
long long binExpMod(int b, int p) {
  if (p == 0) return 1LL;
  if (p % 2 == 1) return (b * binExpMod(b, p - 1)) % MOD;
  long long sqrt_num = binExpMod(b, p / 2);
  return (sqrt_num * sqrt_num) % MOD;
}
vector<int> divs(int n) {
  vector<int> res;
  int i;
  for (i = 1; i * i < n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      res.push_back(n / i);
    }
  }
  if (i * i == n) res.push_back(i);
  sort(res.begin(), res.end());
  return res;
}
int main() {
  int n;
  scanf("%d ", &(n));
  for (int i = 0; i < n; i++) scanf("%d ", &(a[i]));
  sort(a, a + n);
  int bmax = *max_element(a, a + n);
  long long ans = 0;
  for (int bm = 1; bm <= bmax; bm++) {
    vector<int> d = divs(bm);
    vector<int> len;
    for (int i = 0; i < d.size(); i++)
      len.push_back(lower_bound(a, a + n, d[i]) - a);
    for (int i = 0; i < len.size() - 1; i++) len[i] = len[i + 1] - len[i];
    len[len.size() - 1] = n - len[len.size() - 1];
    long long t1 = 1LL, t2 = 1LL;
    for (int i = 0; i < len.size(); i++) {
      t1 = (t1 * binExpMod(i + 1, len[i])) % MOD;
      t2 = (t2 * binExpMod(i + (i == len.size() - 1 ? 0 : 1), len[i])) % MOD;
    }
    ans = (ans + t1 - t2 + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}
