#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int mod = inf + 7;
int v[300100], n, x, first[300100], cm, M, p;
int binpow(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = (res * 1ll * x) % mod;
    x = (x * 1ll * x) % mod;
    y /= 2;
  }
  return res;
}
int calc(int x) {
  cm = 0;
  for (int i = 1; i * i <= x; i++) {
    if (x % i != 0) continue;
    p = x / i;
    v[++cm] = i;
    if (i != p) v[++cm] = p;
  }
  v[++cm] = M + 2;
  sort(v + 1, v + 1 + cm);
  int ra = 1, rb = 1;
  for (int i = 1; i < cm; i++) {
    int e = first[v[i + 1]] - first[v[i]];
    ra = (ra * 1ll * binpow(i, e)) % mod;
  }
  v[cm - 1] = M + 2;
  cm--;
  for (int i = 1; i < cm; i++) {
    int e = first[v[i + 1]] - first[v[i]];
    rb = (rb * 1ll * binpow(i, e)) % mod;
  }
  return (ra - rb + mod) % mod;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    first[x + 1]++;
    M = max(M, x);
  }
  for (int i = 1; i <= M + 2; i++) first[i] += first[i - 1];
  int res = 1;
  for (int i = 2; i <= M; i++) {
    int p = calc(i);
    res += p;
    if (res > mod) res -= mod;
  }
  cout << res;
  return 0;
}
