#include <bits/stdc++.h>
using namespace std;
const int N = 100001, MOD = 1e9 + 7;
int n, m, p, i, a[N];
long long sum, ans;
long long power(long long base, long long exp) {
  long long ans = 1;
  while (exp > 0) {
    if (exp & 1) ans = (ans * base) % MOD;
    exp >>= 1;
    base = (base * base) % MOD;
  }
  return ans;
}
vector<int> getDivisors(int n) {
  vector<int> divs;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      divs.push_back(i);
      if (i * i != n) {
        divs.push_back(n / i);
      }
    }
  }
  sort(divs.begin(), divs.end());
  return divs;
}
int main() {
  cin >> n;
  for (i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  for (int d = a[n - 1]; d > 0; --d) {
    vector<int> divs = getDivisors(d);
    p = lower_bound(a, a + n, d) - a;
    m = n - p;
    sum = (power(divs.size(), m) - power(divs.size() - 1, m)) % MOD;
    sum = (sum + MOD) % MOD;
    while (divs.size() > 1) {
      divs.pop_back();
      i = lower_bound(a, a + n, divs.back()) - a;
      m = p - i;
      p = i;
      sum = (sum * power(divs.size(), m)) % MOD;
    }
    ans = (ans + sum) % MOD;
  }
  cout << ans;
  return 0;
}
