#include <bits/stdc++.h>
using namespace std;
int steps[100010][130];
int how[130];
int mod = 1000000007;
int div(int v) {
  int res = 0;
  for (int i = 1; i * i <= v; ++i) {
    if (v % i == 0) {
      res++;
      int k = v / i;
      if (k != i) res++;
    }
  }
  return res;
}
int dp[100100][130][2];
int r(int p, int v, int was) {
  if (p == 0) return (was == 1);
  if (dp[p][v][was] != -1) return dp[p][v][was];
  int res = r(p - 1, v, 1);
  long long k = v - 1;
  k *= r(p - 1, v, was);
  k %= mod;
  res += k;
  if (res >= mod) res -= mod;
  return dp[p][v][was] = res;
}
int rec(int a, int step) {
  if (step == 0) return 1;
  long long res = rec(a, step / 2);
  res *= res;
  res %= mod;
  if (step & 1) {
    res *= a;
    res %= mod;
  }
  return (int)res;
}
int big[100100];
int a[100100];
int main() {
  memset(dp, -1, sizeof(dp));
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  sort(a, a + n);
  int l = 0;
  for (int i = (0); i < (a[n - 1] + 1); ++i) {
    while (a[l] < i) l++;
    big[i] = n - l;
  }
  int res = 1;
  for (int val = (2); val < (a[n - 1] + 1); ++val) {
    int k = 1;
    memset(how, 0, sizeof(how));
    how[0] = n;
    int cnt = 0;
    for (int i = 1; i * i <= val; ++i) {
      if ((val % i) == 0) {
        cnt++;
        int v = big[i];
        how[cnt] = v;
        how[cnt - 1] -= v;
        k = i;
      }
    }
    for (int i = k; i >= 1; --i) {
      if ((val % i) == 0) {
        if (i * i == val) continue;
        int c = val / i;
        int v = big[c];
        cnt++;
        how[cnt] = v;
        how[cnt - 1] -= v;
      }
    }
    long long cur = r(how[cnt], cnt, 0);
    for (int i = (1); i < (cnt); ++i) {
      cur *= rec(i, how[i]);
      cur %= mod;
    }
    res += cur;
    if (res >= mod) res -= mod;
  }
  cout << res << endl;
  return 0;
}
