#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int mod = 1000000007;
int Fen[200200] = {0};
long long toPow(long long a, int b, long long mod) {
  if (b == 0) return 1;
  if (a == 0) return 0;
  a %= mod;
  if (a < 0) a += mod;
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
void addToFen(int pos) {
  for (int j = pos; j <= 100500; j += j & -j) Fen[j]++;
}
int getFen(int pos) {
  if (pos <= 0) return 0;
  int res = 0;
  for (int j = pos; j > 0; j -= j & -j) res += Fen[j];
  return res;
}
void run() {
  int n;
  cin >> n;
  int A[100100];
  for (int i = (0), ei = (n); i < ei; i++) {
    scanf("%d", A + i);
    addToFen(A[i]);
  }
  long long res = 0;
  int to = *max_element(A, A + n) + 1;
  for (int i = (1), ei = (to); i < ei; i++) {
    vector<int> v;
    int j;
    for (j = 1; j * j < i; j++)
      if (i % j == 0) {
        v.push_back(j);
        v.push_back(i / j);
      }
    if (j * j == i) v.push_back(j);
    v.push_back(100100);
    sort((v).begin(), (v).end());
    long long curr = 1;
    for (int j = (0), ej = (v.size() - 1); j < ej; j++) {
      int cnt = getFen(v[j + 1] - 1) - getFen(v[j] - 1);
      long long mul = toPow(j + 1, cnt, mod);
      if (j == v.size() - 2) {
        mul = (mul - toPow(j, cnt, mod)) % mod;
      }
      curr = (curr * mul) % mod;
    }
    res = (res + curr) % mod;
  }
  res %= mod;
  if (res < 0) res += mod;
  cout << res << endl;
}
int main() {
  run();
  return 0;
}
