#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;
long long po(long long v, long long u) {
  return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1;
}
int n, arr[MAXN];
vector<int> divi[MAXN], vec;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 1; i < MAXN; i++)
    for (int j = i; j < MAXN; j += i) divi[j].push_back(i);
  long long answer = 0;
  for (int i = 1; i <= arr[n - 1]; i++) {
    vec.clear();
    vec.resize(divi[i].size() + 1, n);
    int local = 0;
    for (auto divis : divi[i])
      vec[local++] = lower_bound(arr, arr + n, divis) - arr;
    long long a = 1, b = 0;
    for (int j = 0; j < local; j++) {
      b++;
      a *= po(b, vec[j + 1] - vec[j]);
      a %= MOD;
    }
    answer = (answer + a) % MOD;
    a = 1;
    b = 0;
    vec[local - 1] = n;
    for (int j = 0; j < local; j++) {
      b++;
      a *= po(b, vec[j + 1] - vec[j]);
      a %= MOD;
    }
    answer = (answer + MOD - a) % MOD;
  }
  cout << (answer + 1) % MOD << endl;
  return 0;
}
