#include <bits/stdc++.h>
const long long mod = 1000000007;
long long t[1 + 200][1 + 100000];
long long Chk(long long a) {
  return a >= mod ? a - mod : (a >= 0 ? a : a + mod);
}
long long Mul(long long a, long long b) {
  long long r = 0;
  while (b) {
    if (b & 1) r = Chk(r + a);
    a = Chk(a + a);
    b >>= 1;
  }
  return r;
}
long long Pow(long long a, long long b) {
  if (a > 200) {
    long long r = 1;
    while (b) {
      if (b & 1) r = Mul(r, a);
      a = Mul(a, a);
      b >>= 1;
    }
    return r;
  } else
    return t[a][b];
}
namespace io {
const int I = 1000000;
char buff[I + 10], *a = buff, *b = buff, c;
bool flag;
char getc() {
  if (a == b) {
    b = (a = buff) + fread(buff, 1, I, stdin);
    if (a == b) return EOF;
  }
  return *a++;
}
template <typename T>
inline void read(T &k) {
  while (true) {
    c = getc();
    if (c == '-' || (c >= '0' && c <= '9')) break;
  }
  flag = c == '-' ? 1 : 0;
  k = flag ? 0 : c - '0';
  while (true) {
    c = getc();
    if (c < '0' || c > '9') break;
    k = (k << 3) + (k << 1) + c - '0';
  }
  k = flag ? -k : k;
}
}  // namespace io
using io::read;
namespace shiki {
const int N = 100000;
using std::vector;
int n;
int a[N + 10];
int c[N + 10];
vector<int> p[N + 10];
void ready() {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]), ++c[a[i]];
  for (int k = 1; k <= N; ++k) {
    for (int i = 1; i * i <= k; ++i)
      if (!(k % i)) {
        p[k].push_back(i);
        if (i * i != k) p[k].push_back(k / i);
      }
    std::sort(p[k].begin(), p[k].end());
    c[k] += c[k - 1];
  }
  for (int i = 1; i <= 200; ++i) {
    t[i][0] = 1;
    for (int j = 1; j <= N; ++j) t[i][j] = Mul(t[i][j - 1], i);
  }
}
void solve() {
  long long ans = 1, cal;
  for (int i = 2; i <= N; ++i) {
    cal = 1;
    for (int j = 0, bound = p[i].size() - 1; j < bound; ++j)
      cal = Mul(cal, Pow(j + 1, c[p[i][j + 1] - 1] - c[p[i][j] - 1]));
    int num = n - c[p[i].back() - 1];
    cal = Mul(cal, Chk(Pow(p[i].size(), num) - Pow(p[i].size() - 1, num)));
    ans = Chk(ans + cal);
  }
  std::cout << ans << std::endl;
}
}  // namespace shiki
int main() {
  shiki::ready();
  shiki::solve();
  return 0;
}
