#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000007;
long long qpow(long long b, long long p) {
  long long ans = 1LL;
  while (p) {
    if (p & 1) ans = (ans * b) % Mod;
    b = (b * b) % Mod;
    p >>= 1;
  }
  return ans;
}
int n;
int a[100100];
int to_a[100100];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int j = 1; j <= a[0]; j++) to_a[j] = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = a[i] + 1; j <= a[i + 1]; j++) to_a[j] = i + 1;
  }
  for (int j = a[n - 1] + 1; j <= 100000; j++) to_a[j] = n;
  long long res = 1LL;
  for (int i = 2; i <= 100000; i++) {
    if (to_a[i] >= n) break;
    long long ans0 = 1LL, ans1 = 1LL;
    vector<int> pos;
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        pos.push_back(to_a[j]);
        if (j > 1 && i != j * j) pos.push_back(to_a[i / j]);
      }
    }
    pos.push_back(n);
    sort(pos.begin(), pos.end());
    int cnt = 0;
    for (int i = 0; i < (int)pos.size() - 1; i++) {
      cnt++;
      ans0 = (ans0 * qpow(cnt, pos[i + 1] - pos[i]) % Mod);
    }
    pos.pop_back();
    pos.push_back(to_a[i]);
    pos.push_back(n);
    cnt = 0;
    for (int i = 0; i < (int)pos.size() - 1; i++) {
      cnt++;
      ans1 = (ans1 * qpow(cnt, pos[i + 1] - pos[i]) % Mod);
    }
    res = (res + ans1 - ans0 + Mod) % Mod;
  }
  cout << res << endl;
  return 0;
}
