#include <bits/stdc++.h>
using namespace std;
long long Set(long long N, long long pos) {
  if (pos < 0) return N;
  return N = N | (1ll << pos);
}
long long reset(long long N, long long pos) { return N = N & ~(1ll << pos); }
bool check(long long N, long long pos) {
  if (pos < 0) return 0;
  return (bool)(N & (1ll << pos));
}
void CI(long long &_x) { scanf("%d", &_x); }
void CO(long long &_x) { cout << _x; }
template <typename T>
void getarray(T a[], long long n) {
  for (long long i = 0; i < n; i++) cin >> a[i];
}
template <typename T>
void prLLIarray(T a[], long long n) {
  for (long long i = 0; i < n - 1; i++) cout << a[i] << " ";
  cout << a[n - 1] << endl;
}
const double EPS = 1e-9;
const long long INF = 0x7f7f7f7f;
long long dr8[8] = {1, -1, 0, 0, 1, -1, -1, 1};
long long dc8[8] = {0, 0, -1, 1, 1, 1, -1, -1};
long long dr4[4] = {0, 0, 1, -1};
long long dc4[4] = {-1, 1, 0, 0};
long long kn8r[8] = {1, 2, 2, 1, -1, -2, -2, -1};
long long kn8c[8] = {2, 1, -1, -2, -2, -1, 1, 2};
vector<int> V, div_list;
void divisors(int num) {
  div_list.clear();
  int sq = sqrt(num);
  for (int i = 1; i <= sq; i++)
    if (num % i == 0) {
      div_list.push_back(i);
      if (i != (num / i)) div_list.push_back(num / i);
    }
  sort(div_list.begin(), div_list.end());
}
int kount[100005];
long long pow_(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) {
    return (a * pow_(a, b - 1)) % 1000000007;
  } else {
    long long temp = pow_(a, b / 2);
    return (temp * temp) % 1000000007;
  }
}
int lim;
long long fuck(long long len) {
  if (len == 0) return 0;
  int sz = div_list.size();
  long long ans = 1;
  for (int i = 0; i < len; i++) {
    int a = div_list[i];
    int b;
    if (i + 1 < len)
      b = div_list[i + 1] - 1;
    else
      b = lim;
    ans *= pow_(i + 1, kount[b] - kount[a - 1]);
    ans %= 1000000007;
  }
  return ans;
}
int main() {
  int n, temp;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> temp;
    V.push_back(temp);
    kount[temp]++;
  }
  sort(V.begin(), V.end());
  lim = V[n - 1];
  for (long long i = 1; i <= lim; i++) {
    kount[i] += kount[i - 1];
  }
  long long res = 0;
  for (int i = 1; i <= lim; i++) {
    divisors(i);
    res += fuck(div_list.size());
    res %= 1000000007;
    res -= fuck(div_list.size() - 1);
    res += 1000000007;
    res %= 1000000007;
  }
  cout << res << "\n";
}
