#include <bits/stdc++.h>
using namespace std;
map<int, bool> prExist[200000];
vector<int> Primes[200000];
vector<int> dividers[200000];
int cntpr[200000];
int sum[200000];
int prime[200000];
int a[200000];
bool cmp(int a, int b) { return a < b; }
long long POW(long long n, long long k) {
  if (k == 0) return 1;
  long long res = POW(n, k / 2);
  res = (res * res) % 1000000007ll;
  if (k % 2 == 1) res = (res * n) % 1000000007ll;
  return res;
}
void gogo(int x, int p, int div) {
  if (p >= (int)Primes[x].size()) {
    dividers[x].push_back(div);
    return;
  }
  for (int i = 0; i <= cntpr[Primes[x][p]]; i++)
    gogo(x, p + 1, div * POW(Primes[x][p], i));
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    sum[x]++;
  }
  for (int i = 100000; i >= 0; i--) sum[i] += sum[i + 1];
  for (int i = 2; i * i <= 100000; i++)
    if (prime[i] == 0)
      for (int j = i * i; j <= 100000; j += i) prime[j] = i;
  for (int i = 1; i <= 100000; i++) {
    int x;
    for (x = i; prime[x]; x = x / prime[x]) {
      cntpr[prime[x]]++;
      if (prExist[i][prime[x]] == false) {
        Primes[i].push_back(prime[x]);
        prExist[i][prime[x]] = true;
      }
    }
    if (x > 1 && prExist[i][x] == false) Primes[i].push_back(x);
    if (x > 1) cntpr[x]++;
    gogo(i, 0, 1);
    for (int j = 0; j < (int)Primes[i].size(); j++) cntpr[Primes[i][j]] = 0;
  }
  for (int i = 1; i <= 100000; i++)
    sort(dividers[i].begin(), dividers[i].end(), cmp);
  long long ans = 0;
  for (int i = 1; i <= 100000; i++) {
    long long res = 1, cnt = n;
    for (int j = 1; j < (int)dividers[i].size(); j++) {
      long long newcnt = sum[dividers[i][j]];
      if (newcnt < cnt) res = (res * POW(j, cnt - newcnt)) % 1000000007ll;
      cnt = newcnt;
    }
    if (cnt == 0) break;
    long long newcnt = (POW(dividers[i].size(), cnt) -
                        POW(dividers[i].size() - 1, cnt) + 1000000007ll) %
                       1000000007ll;
    res = (res * newcnt) % 1000000007ll;
    ans = (ans + res) % 1000000007ll;
  }
  cout << ans;
  return 0;
}
