#include <bits/stdc++.h>
using namespace std;
int expo(int a, int b) {
  if (!b) return 1;
  if (b & 1)
    return 1LL * a * expo(1LL * a * a % 1000000007, b >> 1) % 1000000007;
  return expo(1LL * a * a % 1000000007, b >> 1);
}
vector<int> divi[100010];
int n, ans;
int main() {
  int tmp = 0;
  for (int x = 1; x < 100010; x++) {
    vector<int> v;
    for (int d = 1; d * d <= x; d++) {
      if (x % d == 0) {
        divi[x].push_back(d);
        if (d * d < x) v.push_back(x / d);
      }
    }
    reverse(v.begin(), v.end());
    for (int d : v) divi[x].push_back(d);
    tmp += divi[x].size();
  }
  scanf("%d", &n);
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  sort(v.begin(), v.end());
  for (int lcm = 1; lcm < 100010; lcm++) {
    int tmp = 1;
    auto last = v.begin();
    for (int i = 0; i + 1 < divi[lcm].size(); i++) {
      int d = divi[lcm][i], nd = divi[lcm][i + 1];
      auto now = lower_bound(v.begin(), v.end(), nd);
      tmp = 1LL * tmp * expo(i + 1, now - last) % 1000000007;
      last = now;
    }
    int geq = v.end() - last;
    int z = (0LL + expo(divi[lcm].size(), geq) -
             expo(divi[lcm].size() - 1, geq) + 1000000007);
    if (z >= 1000000007) z -= 1000000007;
    tmp = 1LL * tmp * z % 1000000007;
    ans += tmp;
    if (ans >= 1000000007) ans -= 1000000007;
  }
  printf("%d\n", ans);
  return 0;
}
