#include <bits/stdc++.h>
using namespace std;
long long int n, a[200005];
vector<long long int> dvs[100005];
long long int powmod(long long int a, long long int b) {
  if (a == 0) return 0;
  long long int an = 1;
  while (b > 0) {
    if (b & 1) an = (an * a) % 1000000007;
    b >>= 1;
    a = (a * a) % 1000000007;
  }
  return an;
}
int main() {
  scanf("%lld", &n);
  for (long long int i = 1, x; i <= n; i++) scanf("%lld", &x), a[x]++;
  for (int i = 1; i <= 200000; i++) a[i] += a[i - 1];
  long long int ans = 0;
  for (int i = 1; i <= 100000; i++)
    for (int j = i; j <= 100000; j += i) dvs[j].push_back(i);
  for (int i = 1; i <= 100000; i++) dvs[i].push_back(200000);
  for (int i = 1; i <= 100000; i++) {
    long long int an = 1;
    for (int j = 0; j < dvs[i].size() - 1; j++) {
      long long int y = a[dvs[i][j + 1] - 1] - a[dvs[i][j] - 1];
      if (j == dvs[i].size() - 2)
        an = (an *
              ((powmod(j + 1, y) - powmod(j, y) + 1000000007) % 1000000007)) %
             1000000007;
      else
        an = (an * powmod(j + 1, y)) % 1000000007;
    }
    ans = (ans + an) % 1000000007;
  }
  printf("%lld\n", ans);
  return 0;
}
