#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 1e9 + 7;
int n, a[N];
long long bigmod(long long b, long long p) {
  long long t = 1;
  for (; p; b = (b * b) % M, p >>= 1)
    if (p & 1) t = (t * b) % M;
  return t;
}
long long go(int now) {
  vector<int> div;
  for (int i = 1; i * i <= now; i++) {
    if (now % i == 0) {
      div.push_back(i);
      if (i * i != now) div.push_back(now / i);
    }
  }
  div.push_back(N);
  sort(div.begin(), div.end());
  long long last = 1, cur = 1;
  for (int i = 0; i < div.size() - 1; i++) {
    int x = lower_bound(a, a + n, div[i]) - a;
    int y = lower_bound(a, a + n, div[i + 1]) - a;
    long long tmp = bigmod(i + 1, y - x);
    cur *= tmp;
    cur %= M;
  }
  int sz = div.size() - 2;
  div[sz] = N;
  for (int i = 0; i < div.size() - 2; i++) {
    int x = lower_bound(a, a + n, div[i]) - a;
    int y = lower_bound(a, a + n, div[i + 1]) - a;
    long long tmp = bigmod(i + 1, y - x);
    last *= tmp;
    last %= M;
  }
  return (cur - last + M) % M;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long ans = 1;
  for (int i = 1; i < N; i++) {
    ans += go(i);
    ans %= M;
  }
  cout << ans << endl;
  return 0;
}
