#include <bits/stdc++.h>
using namespace std;
int cnt[100001];
int n;
int a[100000];
vector<int> divs[100001];
int mod = 1000000007;
long long binpow(long long x, int n) {
  if (n == 0)
    return 1;
  else if (n == 1)
    return x;
  else if (n & 1)
    return (binpow(x, n - 1) * x) % mod;
  else
    return binpow((x * x) % mod, n >> 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i <= 100000; i++) cnt[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 1; i <= 100000; i++) {
    cnt[i] += cnt[i - 1];
  }
  for (int i = 1; i <= 100000; i++) {
    for (int j = i; j <= 100000; j += i) {
      divs[j].push_back(i);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= 100000; i++) {
    long long koeff = 1;
    int lefts = n;
    for (int j = 1; j < divs[i].size(); j++) {
      int currDiv = divs[i][j];
      int prevDiv = divs[i][j - 1];
      int currCnt = cnt[currDiv - 1] - cnt[prevDiv - 1];
      lefts -= currCnt;
      koeff = (koeff * binpow(j, currCnt)) % mod;
    }
    if (lefts == 0) continue;
    long long lastKoeff =
        binpow(divs[i].size(), lefts) - binpow(divs[i].size() - 1, lefts);
    lastKoeff = (lastKoeff % mod) + mod;
    lastKoeff %= mod;
    lastKoeff = (lastKoeff * koeff) % mod;
    ans = (ans + lastKoeff) % mod;
  }
  cout << ans;
  return 0;
}
