#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
const int MAX = 100 * 1000 + 10;
const int mod = 1e9 + 7;
int A[MAX], n;
int prime[MAX], freq[MAX], cf[MAX];
vector<int> divs[MAX];
vector<int> aux;
void sieve() {
  divs[1].push_back(1);
  for (int i = 2; i < MAX; i++) {
    if (!prime[i]) {
      prime[i] = i;
      for (long long j = i * 1LL * i; j < MAX; j += i) prime[j] = i;
    }
    int p = prime[i], n = i, q = 0;
    while (n % p == 0) n /= p, q++;
    divs[i] = divs[n];
    int s = 0, e = divs[i].size();
    while (q--) {
      for (; s < e; s++) divs[i].push_back(divs[i][s] * p);
      e += ((int)divs[n].size());
    }
    sort(divs[i].begin(), divs[i].end());
  }
}
int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  return x;
}
int mul(int a, int b) { return (a * 1LL * b) % mod; }
int powmod(int x, int p) {
  if (!p) return 1;
  int y = 1;
  for (; p > 1; p >>= 1) {
    if (p & 1) y = mul(x, y);
    x = mul(x, x);
  }
  return mul(x, y);
}
int main() {
  sieve();
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d", A + i), freq[A[i]]++;
  for (int i = 1; i < MAX; i++) cf[i] = cf[i - 1] + freq[i - 1];
  sort(A, A + n);
  int ans = 0;
  for (int lcm = 1; lcm < MAX; lcm++) {
    int m = n - cf[lcm];
    int x = ((int)divs[lcm].size()) - 1;
    int a = add(powmod(x + 1, m), -powmod(x, m)), b = 1;
    aux.clear();
    for (int d : divs[lcm])
      aux.push_back(lower_bound(A, A + n, lcm) - lower_bound(A, A + n, d));
    for (int i = 0; i + 1 < ((int)aux.size()); i++) aux[i] -= aux[i + 1];
    for (int i = 0; i < ((int)aux.size()); i++)
      b = mul(b, powmod(i + 1, aux[i]));
    int tmp = mul(a, b);
    ans = add(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
