#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int MOD = 1e9 + 7;
vector<int> v;
long long f[301][N];
int a[N];
int main() {
  for (int i = 1; i <= 300; i++) {
    f[i][0] = 1;
    for (int j = 1; j < N; j++) {
      f[i][j] = f[i][j - 1] * i % MOD;
    }
  }
  int n, x, sum;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      a[x]++;
    }
    for (int i = 100000; i > 1; i--) a[i - 1] += a[i];
    long long ans = 1;
    for (int i = 2; i <= 100000; i++) {
      if (a[i] == 0) continue;
      v.clear();
      for (int j = 1; j * j <= i; j++) {
        if (i % j == 0) {
          v.push_back(j);
          if (j != i / j) v.push_back(i / j);
        }
      }
      sort(v.begin(), v.end());
      int len = v.size();
      long long ret1 = 1, ret2 = 1;
      sum = 0;
      for (int j = len - 1; j >= 0; j--) {
        if (a[v[j]] <= sum) continue;
        ret1 = ret1 * f[j + 1][a[v[j]] - sum] % MOD;
        sum = a[v[j]];
      }
      sum = 0;
      for (int j = len - 2; j >= 0; j--) {
        if (a[v[j]] <= sum) continue;
        ret2 = ret2 * f[j + 1][a[v[j]] - sum] % MOD;
        sum = a[v[j]];
      }
      ans = ((ans + ret1 - ret2) % MOD + MOD) % MOD;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
