#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<long long> v[100001];
  for (long long i = 1; i <= 100000; i++) {
    for (long long j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        v[i].push_back(j);
        if (j != i / j) v[i].push_back(i / j);
      }
    }
    sort(v[i].begin(), v[i].end());
  }
  long long n, sum = 0;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (long long i = 1; i <= a[n - 1]; i++) {
    long long curr = n, prev = n, ans = 1;
    for (long long j = v[i].size() - 1; j >= 0; j--) {
      long long k = lower_bound(a.begin(), a.end(), v[i][j]) - a.begin();
      if (k == a.size()) break;
      curr = k;
      if (j == v[i].size() - 1) {
        ans *= power(j + 1, prev - curr, 1000000007);
        ans = (ans + 1000000007) % 1000000007;
        ans -= power(j, prev - curr, 1000000007);
        ans = (ans + 1000000007) % 1000000007;
      } else
        ans *= power(j + 1, prev - curr, 1000000007);
      ans = (ans + 1000000007) % 1000000007;
      prev = curr;
    }
    sum = (sum % 1000000007 + ans % 1000000007 + 1000000007) % 1000000007;
  }
  cout << sum << '\n';
}
