#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> fact(100001);
long long fastexp(long long a, long long n) {
  long long z = 1;
  while (n != 0) {
    if (n % 2 == 1) z = (z * a) % 1000000007;
    n = n / 2;
    a = (a * a) % 1000000007;
  }
  return z;
}
void findFactors() {
  for (long long i = 1; i < 100001; i++) {
    for (long long j = i; j < 100001; j += i) {
      fact[j].push_back(i);
    }
  }
}
long long binsearch(vector<long long> &a, long long x, long long y) {
  long long low, mid, high, p = a.size(), q = -1;
  low = 0;
  high = a.size() - 1;
  while (low <= high) {
    mid = (low + high) / 2;
    if (a[mid] < x) {
      low = mid + 1;
    } else {
      p = min(p, mid);
      high = mid - 1;
    }
  }
  low = 0;
  high = a.size() - 1;
  while (low <= high) {
    mid = (low + high) / 2;
    if (a[mid] >= y) {
      high = mid - 1;
    } else {
      q = max(q, mid);
      low = mid + 1;
    }
  }
  return q - p + 1;
}
int main() {
  long long n, i, j, k, p, e, x, y, s = 0;
  cin >> n;
  vector<long long> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  findFactors();
  sort(a.begin(), a.end());
  k = a[n - 1];
  for (i = 1; i <= k; i++) {
    p = 1;
    for (j = 0; j < fact[i].size() - 1; j++) {
      x = fact[i][j];
      y = fact[i][j + 1];
      e = binsearch(a, x, y);
      p = (p * fastexp(j + 1, e)) % 1000000007;
    }
    x = i;
    y = 100001;
    e = binsearch(a, x, y);
    j = (fastexp(fact[i].size(), e) + 1000000007 -
         fastexp(fact[i].size() - 1, e)) %
        1000000007;
    p = (p * j) % 1000000007;
    s = (s + p) % 1000000007;
  }
  cout << s << endl;
  return 0;
}
