#include <bits/stdc++.h>
using namespace std;
long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1ll;
  long long _tmp = mypow(_a, _x / 2, _mod);
  _tmp = (_tmp * _tmp) % _mod;
  if (_x & 1) _tmp = (_tmp * _a) % _mod;
  return _tmp;
}
bool equal(double _x, double _y) { return _x > _y - 1e-9 && _x < _y + 1e-9; }
int __ = 1, cs;
vector<long long> fac[100010];
void build() {
  for (int i = 1; i < 100010; i++)
    for (int j = i; j < 100010; j += i) fac[j].push_back(i);
}
long long n, a[100010], ans, ma;
void init() {
  n = getint();
  for (int i = 1; i <= n; i++) {
    long long tmp = getint();
    a[tmp]++;
    ma = max(tmp, ma);
  }
  for (int i = ma - 1; i >= 0; i--) a[i] += a[i + 1];
}
void solve() {
  for (long long i = 1; i <= ma; i++) {
    long long tans = 1ll;
    for (long long j = 0; j < (int)fac[i].size(); j++)
      if (j == (int)fac[i].size() - 1)
        tans = (tans * (mypow((j + 1ll), a[fac[i][j]], 1000000007ll) -
                        mypow(j, a[fac[i][j]], 1000000007ll) + 1000000007ll)) %
               1000000007ll;
      else
        tans = (tans * mypow((j + 1ll), a[fac[i][j]] - a[fac[i][j + 1]],
                             1000000007ll)) %
               1000000007ll;
    ans = (ans + tans) % 1000000007ll;
  }
  cout << ans << endl;
}
int main() {
  build();
  while (__--) {
    init();
    solve();
  }
}
