#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\t";
  err(++it, args...);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2>& v) {
  c << "(" << v.first << "," << v.second << ")";
  return c;
}
template <template <class...> class TT, class... T>
ostream& operator<<(ostream& out, TT<T...>& c) {
  out << "{ ";
  for (auto& x : c) out << x << " ";
  out << "}";
  return out;
}
const int LIM = 1e5 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y, w;
inline long long powm(long long x, long long pw, long long Mod = MOD) {
  x %= Mod;
  long long res = 1;
  while (pw) {
    if (pw & 1LL) res = ((res * x)) % Mod;
    pw >>= 1;
    x = ((x * x)) % Mod;
  }
  return res;
}
inline long long inv(long long x, long long Mod = MOD) {
  return powm(x, Mod - 2, Mod);
}
long long iv[LIM], oneup[LIM], occ[LIM], occ1[LIM];
int cnt[LIM], cnt1[LIM];
void pre() {
  iv[1] = 1;
  for (int i = 2; i < LIM; ++i) iv[i] = MOD - (MOD / i) * iv[MOD % i] % MOD;
  for (int i = 1; i < LIM; ++i) oneup[i] = (i + 1) * iv[i] % MOD;
  for (int i = 0; i < LIM; ++i) occ[i] = occ1[i] = cnt[i] = cnt1[i] = 1;
  occ1[1] = 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  pre();
  cin >> n;
  int f[LIM] = {0};
  for (int i = 0; i < n; ++i) cin >> x, f[x]++;
  for (int i = LIM - 2; i >= 0; --i) f[i] += f[i + 1];
  for (int i = 2; i < LIM; ++i) {
    if (f[i] == 0) break;
    for (int j = i; j < LIM; j += i) {
      occ[j] = occ[j] * powm(oneup[cnt[j]], f[i]) % MOD;
      cnt[j]++;
    }
    for (int j = 2 * i; j < LIM; j += i) {
      occ1[j] = occ1[j] * powm(oneup[cnt1[j]], f[i]) % MOD;
      cnt1[j]++;
    }
  }
  long long ans = 0;
  for (int i = 1; i < LIM; ++i) {
    ans += occ[i] - occ1[i];
  }
  ans %= MOD;
  ans += MOD;
  ans %= MOD;
  cout << ans << '\n';
  return 0;
}
