#include <bits/stdc++.h>
using namespace std;
int a[100001], cnt[100001], N, deg[100001], adj[100001][130];
long long po[130][100001], res[100001];
int main() {
  int mx, x, k, i, j;
  long long tmp;
  for (i = 1; i < 130; i++)
    for (j = 0; j < 100001; j++) {
      if (j == 0)
        po[i][j] = 1;
      else
        po[i][j] = po[i][j - 1] * i % 1000000007;
    }
  for (i = 1; i < 100001; i++) {
    for (j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        adj[i][deg[i]++] = j;
        if (j * j < i) {
          adj[i][deg[i]++] = i / j;
        }
      }
    }
    sort(adj[i], adj[i] + deg[i]);
  }
  scanf("%d", &N);
  memset(cnt, 0, sizeof(cnt));
  for (i = 0; i < N; i++) {
    scanf("%d", a + i);
    cnt[a[i]]++;
  }
  mx = *max_element(a, a + N);
  for (i = 100001 - 2; i >= 1; i--) cnt[i] += cnt[i + 1];
  long long sum = 0;
  for (i = 2; i <= mx; i++) {
    x = 0;
    tmp = 1;
    for (j = deg[i] - 1; j >= 0; j--) {
      k = cnt[adj[i][j]] - x;
      x = cnt[adj[i][j]];
      tmp = tmp * po[j + 1][k] % 1000000007;
    }
    res[i] = tmp;
    x = 0;
    tmp = 1;
    for (j = deg[i] - 2; j >= 0; j--) {
      k = cnt[adj[i][j]] - x;
      x = cnt[adj[i][j]];
      tmp = tmp * po[j + 1][k] % 1000000007;
    }
    res[i] -= tmp;
    if (res[i] < 0) res[i] += 1000000007;
    sum += res[i];
  }
  sum++;
  printf("%I64d\n", sum % 1000000007);
  return 0;
}
