#include <bits/stdc++.h>
using namespace std;
int Pow(int x, int y) {
  int res = 1;
  while (y > 0) {
    if ((y & 1) == 1) {
      res = 1LL * res * x % 1000000007;
    }
    y >>= 1;
    x = 1LL * x * x % 1000000007;
  }
  return res;
}
int Cnt[100010];
vector<int> B[100010];
int main() {
  int n, i, j, Mx = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    Cnt[x]++;
    Mx = max(Mx, x);
  }
  for (i = 2; i <= Mx + 1; i++) {
    Cnt[i] += Cnt[i - 1];
  }
  for (i = 1; i <= Mx; i++) {
    for (j = i; j <= Mx; j += i) {
      B[j].push_back(i);
    }
  }
  int Ans = 0;
  for (i = 1; i <= Mx; i++) {
    B[i].push_back(Mx + 1);
    int Las = 1, sum1 = 1, sum2 = 1, len = (int)B[i].size();
    for (j = 1; j < len; j++) {
      int x = B[i][j];
      sum1 = 1LL * sum1 * Pow(min(j, len - 2), Cnt[x - 1] - Cnt[Las - 1]) %
             1000000007;
      sum2 = 1LL * sum2 * Pow(j, Cnt[x - 1] - Cnt[Las - 1]) % 1000000007;
      Las = x;
    }
    Ans = (Ans + sum2 - sum1) % 1000000007;
  }
  if (Ans < 0) {
    Ans += 1000000007;
  }
  printf("%d\n", Ans);
  return 0;
}
