#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, a[N];
vector<int> get_divisors(int u) {
  vector<int> res;
  for (int i = 1; i * i <= u; ++i) {
    if (u % i == 0) {
      res.push_back(i);
      if (i != u / i) res.push_back(u / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
int add(int a, int b) { return (a + b) % mod; }
int sub(int a, int b) {
  long long result = a - b;
  if (result < 0) result += mod;
  return result;
}
long long mul(long long a, long long b) { return (a * b) % mod; }
int modpow(int base, int exp) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2) res = (res * base) % mod;
    base = (1ll * base * base) % mod;
    exp /= 2;
  }
  return (int)res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long res = 0;
  for (int i = 1; i <= a[n - 1]; ++i) {
    vector<int> divisors = get_divisors(i);
    int prev = -1, dsz = divisors.size();
    long long toAdd = 1;
    for (int j = 1; j < dsz; ++j) {
      int pos = lower_bound(a, a + n, divisors[j]) - a - 1;
      int count = pos - prev;
      toAdd = mul(toAdd, modpow(j, count));
      prev = pos;
    }
    int count = n - 1 - prev;
    assert(count > 0);
    long long added_value = modpow(dsz, count);
    added_value = sub(added_value, modpow(dsz - 1, count));
    toAdd = mul(toAdd, added_value);
    res = add(res, toAdd);
  }
  cout << res << endl;
  return 0;
}
