#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
const int INF = (int)1e9;
const long long INF64 = (long long)1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
long long modulo = 1e9 + 7;
long long binpow(long long value, long deg) {
  if (deg == 0) return 1ll;
  if (deg % 2 == 1) {
    return (binpow(value, deg - 1) * value) % modulo;
  }
  long long val = binpow(value, deg >> 1);
  return (val * val) % modulo;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < int((int)(a).size()); ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  long long answer = 0;
  for (int lcm = 1; lcm <= 1e5; lcm++) {
    vector<int> div;
    for (int j = 1; j * j <= lcm; j++) {
      if (lcm % j == 0) {
        div.push_back(j);
        if (j != (lcm / j)) div.push_back(lcm / j);
      }
    }
    sort((div).begin(), (div).end());
    long long tcnt = 1;
    for (int j = 0; j + 1 < div.size(); j++) {
      int deg = lower_bound((a).begin(), (a).end(), div[j + 1]) -
                lower_bound((a).begin(), (a).end(), div[j]);
      tcnt *= binpow(j + 1, deg);
      tcnt %= modulo;
    }
    int deg = a.end() - lower_bound((a).begin(), (a).end(), lcm);
    if (deg) {
      tcnt *= (binpow((int)(div).size(), deg) + modulo -
               binpow((int)(div).size() - 1, deg));
      tcnt %= modulo;
      answer += tcnt;
    }
  }
  answer %= modulo;
  cout << answer << endl;
}
