#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = (1LL << 61);
const int inf = (1 << 30);
const int nmax = 1e5 + 50;
const int M = 1e5;
const int mod = 1e9 + 7;
using namespace std;
int i, a[nmax], s[nmax], n;
vector<int> v;
long long pw(long long a, int b) {
  long long ans = 1;
  for (int i = 0; i <= 20; i++) {
    if (b & (1 << i)) ans = (ans * a) % mod;
    a = (a * a) % mod;
  }
  return ans;
}
long long f(int x) {
  int i;
  v.clear();
  for (i = 1; i * i <= x; i++)
    if (x % i == 0) {
      v.push_back(i);
      if (i * i != x) v.push_back(x / i);
    }
  sort(v.begin(), v.end());
  long long p1 = 1, p2 = 1;
  int sz = v.size();
  v.push_back(100005);
  for (i = 0; i < sz; i++) p1 = p1 * pw(i + 1, a[v[i + 1]] - a[v[i]]) % mod;
  v[sz - 1] = 100005;
  for (i = 0; i < sz - 1; i++) p2 = p2 * pw(i + 1, a[v[i + 1]] - a[v[i]]) % mod;
  return (p1 - p2 + mod) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) {
    int x;
    cin >> x;
    s[x]++;
  }
  for (i = 0; i <= M + 6; i++) a[i + 1] = s[i] + a[i];
  long long ans = 1;
  for (i = 2; i <= M; i++) {
    long long tmp = f(i);
    ans = (ans + tmp) % mod;
  }
  cout << ans << endl;
  return 0;
}
