#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
int n, ma;
long long ans = 1;
int s[100010];
long long mod_pow(long long k, int n) {
  if (!n) return 1LL;
  long long tmp = mod_pow(k, n / 2);
  tmp *= tmp;
  tmp %= 1000000007LL;
  if (n & 1) tmp *= k;
  tmp %= 1000000007LL;
  return tmp;
}
long long solve(int k) {
  vector<int> yaku;
  long long res1 = 1LL;
  long long res2 = 1LL;
  for (int i = 1; i * i <= k; i++) {
    if (k % i == 0) {
      yaku.push_back(i);
      if (i * i != k) yaku.push_back(k / i);
    }
  }
  sort(yaku.begin(), yaku.end());
  int sz = (int)yaku.size();
  yaku.push_back(ma + 1);
  for (int i = (0); i < (sz); ++i)
    res1 = res1 * mod_pow(i + 1, s[yaku[i + 1]] - s[yaku[i]]) % 1000000007LL;
  yaku[sz - 1] = ma + 1;
  for (int i = (0); i < (sz - 1); ++i)
    res2 = res2 * mod_pow(i + 1, s[yaku[i + 1]] - s[yaku[i]]) % 1000000007LL;
  return (res1 - res2 + 1000000007LL) % 1000000007LL;
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    int a;
    scanf("%d", &a);
    s[a + 1]++;
    ma = max(ma, a);
  }
  for (int i = (0); i < (ma + 1); ++i) s[i + 1] += s[i];
  for (int i = 2; i <= ma; i++) ans = (ans + solve(i)) % 1000000007LL;
  cout << ans << endl;
  return 0;
}
