#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, z, e, ans, a[100100], ta[140][100010], mod = 1e9 + 7;
set<long long> s[100100];
long long bs(long long bb, long long ee, long long val) {
  if (ee - bb <= 1) return bb;
  long long mid = (bb + ee) / 2;
  if (a[mid] >= val)
    return bs(bb, mid, val);
  else
    return bs(mid, ee, val);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  for (int i = 1; i <= 1e5; i++) {
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        s[i].insert(j);
        s[i].insert(i / j);
      }
    }
  }
  for (int i = 1; i < 130; i++) {
    ta[i][0] = 1;
    for (int j = 1; j < 100001; j++) {
      (ta[i][j] = ta[i][j - 1] * i) %= mod;
    }
  }
  cin >> n;
  a[0] = -1e13;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a, a + n + 1);
  x = 1;
  for (int i = 1; i < 100001; i++) {
    while (a[x] < i) {
      x++;
      if (x > n) return cout << ans, 0;
    }
    (z = (ta[s[i].size()][n - x + 1] - ta[s[i].size() - 1][n - x + 1]) +
         ((ta[s[i].size()][n - x + 1] - ta[s[i].size() - 1][n - x + 1]) < 0) *
             mod) %= mod;
    e = x;
    s[i].erase(i);
    while (!s[i].empty()) {
      y = *s[i].rbegin();
      s[i].erase(y);
      m = bs(0, n, y);
      if (m + 1 >= e) continue;
      (z *= ta[s[i].size() + 1][e - m - 1]) %= mod;
      e = m + 1;
    }
    (ans += z) %= mod;
  }
  cout << ans;
  return 0;
}
