#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int mod = 1000000007;
int n;
int a[N];
int freq[N];
int s[N];
long long fast_pow(long long x, int n) {
  if (!n) return 1;
  long long y = fast_pow(x, n / 2);
  y = y * y % mod;
  if (n & 1) y = y * x % mod;
  return y;
}
long long solve(int x) {
  vector<int> v;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i) continue;
    v.push_back(i);
    if (x / i != i) v.push_back(x / i);
  }
  sort((v).begin(), (v).end());
  int sz = v.size();
  v.push_back(N - 1);
  long long p1 = 1;
  for (int i = (0), _b = (sz); i < (_b); ++i)
    p1 = p1 * fast_pow(i + 1, s[v[i + 1]] - s[v[i]]) % mod;
  v[sz - 1] = N - 1;
  long long p2 = 1;
  for (int i = (0), _b = (sz - 1); i < (_b); ++i)
    p2 = p2 * fast_pow(i + 1, s[v[i + 1]] - s[v[i]]) % mod;
  return (p1 - p2 + mod) % mod;
}
int main(int argc, char *argv[]) {
  cin >> n;
  for (int i = (0), _b = (n); i < (_b); ++i) cin >> a[i];
  for (int i = (0), _b = (n); i < (_b); ++i) freq[a[i]]++;
  for (int i = (0), _b = (N - 1); i < (_b); ++i) s[i + 1] = s[i] + freq[i];
  long long ans = 1;
  for (int i = (2), _b = (N); i < (_b); ++i) ans = (ans + solve(i)) % mod;
  cout << ans << endl;
  return 0;
}
