#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using namespace std;
const double PI = acos(-1);
long long gcd() { return 0ll; }
template <typename T, typename... Args>
T gcd(T a, Args... args) {
  return __gcd(a, (__typeof(a))gcd(args...));
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    b >>= 1;
    a = (a * a) % 1000000007;
  }
  return res;
}
vector<int> v[100001];
void seive() {
  for (__typeof(100001) i = (1) - ((1) > (100001));
       i != (100001) - ((1) > (100001)); i += 1 - 2 * ((1) > (100001)))
    for (int j = i; j < 100001; j += i) v[j].emplace_back(i);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    seive();
    int n;
    cin >> n;
    long long a[n];
    for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
         i += 1 - 2 * ((0) > (n)))
      cin >> a[i];
    sort(a, a + n);
    long long pre = n, cur, ans = 0, sum;
    for (__typeof(1) i = (a[n - 1] + 1) - ((a[n - 1] + 1) > (1));
         i != (1) - ((a[n - 1] + 1) > (1));
         i += 1 - 2 * ((a[n - 1] + 1) > (1))) {
      pre = n;
      cur = lower_bound(a, a + pre, v[i].back()) - a;
      sum = power(v[i].size(), pre - cur) - power(v[i].size() - 1, pre - cur);
      sum = (sum + 1000000007) % 1000000007;
      pre = cur;
      for (__typeof(0) j = (v[i].size() - 1) - ((v[i].size() - 1) > (0));
           j != (0) - ((v[i].size() - 1) > (0));
           j += 1 - 2 * ((v[i].size() - 1) > (0))) {
        cur = lower_bound(a, a + pre, v[i][j]) - a;
        sum = (sum * power(j + 1, pre - cur)) % 1000000007;
        pre = cur;
      }
      ans = (ans + sum) % 1000000007;
    }
    cout << ans << "\n";
  }
  return 0;
}
