#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n1, long long n2) {
  if (n1 % n2 == 0) return n2;
  return gcd(n2, n1 % n2);
}
long long powmod(long long base, long long exponent) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % 1000000007;
    base = (base * base) % 1000000007;
    exponent /= 2;
  }
  return ans;
}
int a[100100 + 1];
int dp[100100 + 1];
vector<int> factors[100100 + 1];
int main() {
  int n, i, j, mx = 0, m;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    dp[a[i]]++;
    mx = max(mx, a[i]);
  }
  mx++;
  for (i = mx - 1; i >= 0; i--) dp[i] += dp[i + 1];
  for (i = 1; i < mx; i++)
    for (j = i; j < mx; j += i) factors[j].push_back(i);
  for (i = 1; i < mx; i++) factors[i].push_back(mx);
  long long answer = 0, temp, temp1;
  for (m = mx - 1; m >= 1; m--) {
    temp = 1;
    int p = factors[m].size() - 1;
    for (i = 0; i < p; i++) {
      temp1 = powmod(i + 1, dp[factors[m][i]] - dp[factors[m][i + 1]]);
      if (i == p - 1)
        temp1 -= powmod(i, dp[factors[m][i]] - dp[factors[m][i + 1]]);
      temp1 = ((temp1 % 1000000007) + 1000000007) % 1000000007;
      temp = (temp * temp1) % 1000000007;
    }
    temp %= 1000000007;
    answer += temp;
    if (answer >= 1000000007) answer -= 1000000007;
  }
  printf("%lld", answer);
  return 0;
}
