#include <bits/stdc++.h>
using namespace std;
int dv[100060][300];
int sz[100060];
void build() {
  int i, j;
  for (i = 1; i < 100060; i++) {
    for (j = i; j < 100060; j += i) dv[j][sz[j]++] = i;
  }
  return;
}
long long int pro(long long int a, long long int b) {
  if (b == 0 || a == 0) return 0;
  long long int d = a * b;
  if (d % a == 0 && d % b == 0 && d > 0)
    return d % 1000000007;
  else if (b % 2 == 0)
    return pro((a + a) % 1000000007, b / 2);
  else if (b % 2 == 1)
    return (a + pro((a + a) % 1000000007, b / 2)) % 1000000007;
}
long long int bit(long long int a, long long int b) {
  long long int x = 1;
  while (b > 0) {
    if (b & 1) x = pro(x, a);
    b = b >> 1;
    a = pro(a, a);
  }
  return x;
}
int main() {
  int n, m = 0, i, j, x, s, a;
  scanf("%d", &n);
  vector<int> hash(100060, 0), fre(100060, 0);
  for (i = 0; i < n; i++) scanf("%d", &x), hash[x]++, m = max(m, x);
  for (i = 1; i < 100060; i++) fre[i] = hash[i] + fre[i - 1];
  long long int p, ans = 0;
  build();
  for (i = 1; i <= m; i++) {
    s = sz[i], a = fre[100060 - 1] - fre[i - 1];
    p = bit(s, a) - bit(s - 1, a) + 1000000007;
    for (j = 1; j < s; j++)
      p = pro(p, bit(j, fre[dv[i][j] - 1] - fre[dv[i][j - 1] - 1]));
    ans += p;
  }
  cout << ans % 1000000007 << endl;
}
