#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int maxn = 1e5 + 15;
const int inf = 1e9;
const int maxe = 200000;
vector<int> vec[maxn];
int small[maxn];
int same[maxn];
int a[maxn];
int N;
void init(int n) {
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i) vec[j].push_back(i);
  for (int i = 1; i <= n; i++) {
    small[i] = lower_bound(a, a + N, i) - a;
    same[i] = upper_bound(a, a + N, i) - a - small[i];
  }
}
long long powmod(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b = b / 2;
  }
  return ans;
}
int main() {
  int maxx = 0;
  ;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    maxx = max(maxx, a[i]);
  }
  sort(a, a + N);
  init(maxx);
  long long sum = 1;
  for (int i = maxx; i > 1; i--) {
    long long ans = 1;
    int len = vec[i].size();
    for (int j = 0; j < len - 1; j++) {
      int now = vec[i][j];
      int next = vec[i][j + 1];
      int cnt = small[next] - small[now];
      ans = ans * powmod(j + 1, cnt, mod) % mod;
    }
    int cnt = N - small[vec[i][len - 1]];
    ans = ans *
          ((powmod(len, cnt, mod) - powmod(len - 1, cnt, mod) + mod) % mod) %
          mod;
    sum = (sum + ans) % mod;
  }
  printf("%lld\n", sum);
}
