#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int mod = 1e9 + 7;
int n, a[N];
long long work(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret *= a, ret %= mod;
    a *= a;
    a %= mod;
    b >>= 1;
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  sort(a, a + n);
  long long sum = 0;
  for (int k = 1; k <= a[n - 1]; k++) {
    vector<int> vt;
    for (int i = 1; i * i <= k; i++) {
      if (k % i) continue;
      vt.push_back(i);
      if (i * i == k) continue;
      vt.push_back(k / i);
    }
    sort(vt.begin(), vt.end());
    long long ret = 1;
    for (int i = 0, j = 0; i < (int((vt).size())); i++) {
      int t = lower_bound(a, a + n, vt[i]) - lower_bound(a, a + n, j);
      if (t == 0) continue;
      j = vt[i];
      ret *= work(i, t);
      ret %= mod;
    }
    int t = a + n - lower_bound(a, a + n, k);
    ret *= (work((int((vt).size())), t) - work((int((vt).size())) - 1, t));
    ret %= mod;
    ret += mod;
    ret %= mod;
    sum += ret;
    sum %= mod;
  }
  cout << sum << endl;
  return 0;
}
