#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17 + 9;
long long mult(long long a, long long b) { return a * b % 1000000007; }
long long fastpow(long long a, long long b) {
  long long calc = 1;
  for (; b >= 1LL; b /= 2LL) {
    if ((b & 1LL)) calc = mult(calc, a);
    a = mult(a, a);
  }
  return calc;
}
long long soma(long long a, long long b) {
  if (a + b > 1000000007)
    return a + b - 1000000007;
  else
    return a + b;
}
long long subt(long long a, long long b) {
  if (a - b < 0)
    return a - b + 1000000007;
  else
    return a - b;
}
long long arrc[100009];
long long vet[100009];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(arrc, 0, sizeof arrc);
  long long n;
  cin >> n;
  long long maxi = -1;
  for (long long i = 0; i < (n); ++i) {
    cin >> vet[i];
    arrc[vet[i]]++;
    maxi = max(vet[i], maxi);
  }
  for (long long i = 100009 - 1 - 1; i >= 0; i--) {
    arrc[i] += arrc[i + 1];
  }
  long long anstotal = 0;
  for (long long j = 1; j < (maxi + 1); ++j) {
    vector<int> divs;
    for (int i = 1; i <= sqrt(j); i++) {
      if (j % i == 0) {
        if (j / i != i)
          divs.push_back(j / i), divs.push_back(i);
        else
          divs.push_back(i);
      }
    }
    sort(divs.rbegin(), divs.rend());
    long long qtdant = 0;
    long long ans = 1;
    int possi = (long long)(divs).size();
    for (auto e : divs) {
      if (e != j)
        ans = mult(ans, fastpow(possi, arrc[e] - qtdant));
      else
        ans = mult(ans, subt(fastpow(possi, arrc[e] - qtdant),
                             fastpow(possi - 1, arrc[e] - qtdant)));
      possi--;
      qtdant = arrc[e];
    }
    anstotal = soma(anstotal, ans);
  }
  cout << anstotal << "\n";
  return 0;
}
