#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, N = 1e5 + 10, P = 1e9 + 7;
template <class T>
inline bool chkmin(T &A, T B) {
  return B < A ? A = B, 1 : 0;
}
template <class T>
inline bool chkmax(T &A, T B) {
  return A < B ? A = B, 1 : 0;
}
template <class T, class _>
inline void Add(T &first, _ second) {
  first += second;
  if (first >= P) first -= P;
  if (first < 0) first += P;
}
int n, A[N], cnt[N];
long long ans;
vector<int> E;
long long Pow(long long first, long long k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * first % P;
    first = first * first % P;
    k >>= 1;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = (1), i_end = (n); i <= i_end; ++i) {
    scanf("%d", &A[i]);
    cnt[A[i]]++;
  }
  for (int i = (N - 10), i_end = (0); i >= i_end; --i) cnt[i] += cnt[i + 1];
  for (int i = (1), i_end = (N - 10); i <= i_end; ++i) {
    E.clear();
    for (int j = (1), j_end = (sqrt(i)); j <= j_end; ++j)
      if (i % j == 0) {
        E.push_back(j);
        if (i / j != j) E.push_back(i / j);
      }
    sort(E.begin(), E.end());
    int sz = E.size();
    long long res = (Pow(sz, cnt[i]) - Pow(sz - 1, cnt[i]) + P) % P;
    for (int i = (0), i_end = (sz - 2); i <= i_end; ++i)
      res = res * Pow(i + 1, cnt[E[i]] - cnt[E[i + 1]]) % P;
    Add(ans, res);
  }
  printf("%lld\n", ans);
  return 0;
}
