#include <bits/stdc++.h>
using namespace std;
long long Power(long long BaSe, long long PoWeR, long long MoD) {
  BaSe %= MoD;
  long long ret = 1;
  while (PoWeR > 0) {
    if (PoWeR & 1) ret = (ret * BaSe) % MoD;
    PoWeR >>= 1;
    BaSe = (BaSe * BaSe) % MoD;
  }
  return ret;
}
long long a[100010], p[1010], t, mx = 0;
void find_d(long long x) {
  t = 0;
  long long cur = 1;
  while (cur * cur <= x) {
    if (x % cur == 0) {
      p[t++] = cur;
      if (cur * cur < x) p[t++] = x / cur;
    }
    cur++;
  }
  sort(p, p + t), p[t] = mx + 1;
}
int main() {
  long long n, x, ans = 0, q, cur;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &x);
    a[x]++;
    mx = mx > x ? mx : x;
  }
  for (long long i = 1; i <= mx; i++) a[i] += a[i - 1];
  for (long long i = 1; i <= mx; i++) {
    find_d(i);
    x = 1;
    for (long long j = 0; j < t; j++) {
      q = a[p[j + 1] - 1] - a[p[j] - 1];
      cur = Power(j + 1, q, 1000000007);
      if (j == t - 1)
        cur = (cur - Power(j, q, 1000000007) + 1000000007) % 1000000007;
      x *= cur;
      x %= 1000000007;
    }
    ans = (ans + x) % 1000000007;
  }
  printf("%lld\n", ans);
  return 0;
}
