#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAXN = 100005;
int a[MAXN];
int stk[MAXN];
int siz[MAXN];
int isprime[MAXN];
int prime[MAXN];
int q[MAXN];
int pos[MAXN];
int dp[MAXN];
int tol;
int sz;
int top;
int add(int x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0) x += MOD;
  return x;
}
void getprime() {
  isprime[1] = 1;
  sz = 0;
  for (int i = 2; i <= 100000; i++) {
    if (isprime[i] == 0) {
      prime[sz++] = i;
      for (long long j = (long long)i * i; j <= 100000; j += i) isprime[j] = 1;
    }
  }
}
void getdivisors(int x) {
  top = 0;
  int res = (int)sqrt(x + 0.5);
  for (int i = 0; i < sz && prime[i] <= res; i++) {
    int y = prime[i];
    if (x % y != 0) continue;
    stk[top++] = y;
    int j = 0;
    while (x % y == 0) {
      x /= y;
      ++j;
    }
    siz[top - 1] = j;
  }
  if (x > 1) {
    stk[top++] = x;
    siz[top - 1] = 1;
  }
}
int mpow(int x, int n) {
  int ans = 1;
  int temp = x;
  while (n) {
    if (n & 1) ans = (long long)ans * temp % MOD;
    n >>= 1;
    temp = (long long)temp * temp % MOD;
  }
  return ans;
}
void dfs(int cent, int val) {
  if (cent == top) {
    q[tol++] = val;
    return;
  }
  dfs(cent + 1, val);
  for (int i = 1; i <= siz[cent]; i++) dfs(cent + 1, val * mpow(stk[cent], i));
}
int erfen(int l, int r, int x) {
  int po = r + 1;
  while (l <= r) {
    int m = l + r >> 1;
    if (a[m] >= x) {
      po = m;
      r = m - 1;
    } else
      l = m + 1;
  }
  return po;
}
int main() {
  getprime();
  int n, mx = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
  }
  sort(a + 1, a + n + 1);
  int ans = 0;
  for (int i = 1; i <= mx; i++) {
    getdivisors(i);
    tol = 0;
    dfs(0, 1);
    sort(q, q + tol);
    for (int j = 0; j < tol; j++) {
      pos[j] = erfen(1, n, q[j]);
    }
    pos[tol] = n + 1;
    for (int j = 0; j < tol; j++) {
      dp[j] = pos[j + 1] - pos[j];
    }
    int temp = 1;
    for (int j = 0; j < tol; j++) {
      if (j == tol - 1) {
        int temp2 = (long long)temp * mpow(j, dp[j]) % MOD;
        temp = (long long)temp * mpow(j + 1, dp[j]) % MOD;
        temp = sub(temp, temp2);
      } else
        temp = (long long)temp * mpow(j + 1, dp[j]) % MOD;
    }
    ans = add(ans, temp);
  }
  printf("%d\n", ans);
  return 0;
}
