#include <bits/stdc++.h>
using namespace std;
vector<int> factor[100001];
void precal() {
  for (int i = (1); i < (100001); ++i)
    for (int j = (i); j < (100001); j += (i)) factor[j].push_back(i);
}
int expo(int a, int b) {
  if (b == 0) return 1;
  if (b == 1) return a % 1000000007;
  int c = expo(a, b >> 1);
  c = ((long long)c * c) % 1000000007;
  if (b & 1) c = ((long long)c * a) % 1000000007;
  return c;
}
int main(int argc, char **argv) {
  int N;
  scanf("%d", &N);
  vector<int> A(N);
  for (int i = (0); i < (N); ++i) scanf("%d", &A[i]);
  sort(A.begin(), A.end());
  precal();
  int res = 0;
  for (int f = (1); f < (100001); ++f) {
    int numFactor = factor[f].size();
    int bound[numFactor];
    int cur = 0;
    for (int i = (0); i < (numFactor); ++i) {
      int lo = cur, hi = N - 1;
      int nextFactor = (i + 1 == numFactor) ? (1 << 29) : factor[f][i + 1];
      while (lo <= hi) {
        int mi = (lo + hi) / 2;
        if (A[mi] >= nextFactor)
          hi = mi - 1;
        else
          lo = mi + 1;
      }
      bound[i] = lo - cur;
      cur = lo;
    }
    if (!bound[numFactor - 1]) continue;
    int countWays = 1;
    for (int i = (0); i < (numFactor - 1); ++i)
      countWays = ((long long)countWays * expo(i + 1, bound[i])) % 1000000007;
    countWays = ((long long)countWays *
                 (((long long)expo(numFactor, bound[numFactor - 1]) +
                   1000000007 - expo(numFactor - 1, bound[numFactor - 1])) %
                  1000000007)) %
                1000000007;
    res = (res + countWays) % 1000000007;
  }
  cout << res;
  return 0;
}
