#include <bits/stdc++.h>
using namespace std;
const int kMod = 1000 * 1000 * 1000 + 7;
const int kN = 100 * 1000 + 1;
const int kInf = 1000 * 1000 * 1000;
vector<int> divisors[kN];
string str;
void PreCalc() {
  for (int n = 1; n < kN; ++n) {
    int d;
    for (d = 1; d * d < n; ++d)
      if (n % d == 0) {
        divisors[n].push_back(d);
        divisors[n].push_back(n / d);
      }
    if (d * d == n) divisors[n].push_back(d);
    sort(divisors[n].begin(), divisors[n].end());
  }
}
int Power(int a, int n) {
  long long res = 1;
  long long b = a;
  while (n) {
    if (n & 1) res = (res * b) % kMod;
    b = (b * b) % kMod;
    n >>= 1;
  }
  return (int)res;
}
int Reverse(int a) { return Power(a, kMod - 2); }
vector<int> sum;
int RMQ(int l) { return (l < 0 || l >= sum.size() ? 0 : sum[l]); }
int RMQ(int l, int r) { return (l > r ? 0 : RMQ(r) - RMQ(l - 1)); }
int main() {
  PreCalc();
  int n;
  cin >> n;
  vector<int> inp(n);
  for (int i = 0; i < n; ++i) cin >> inp[i];
  sort(inp.begin(), inp.end());
  vector<pair<int, int> > arr;
  int prev = -1;
  for (int i = 0; i < n; ++i) {
    if (prev != inp[i])
      arr.push_back(make_pair(inp[i], 1));
    else
      ++arr.back().second;
  }
  sum.push_back(arr[0].second);
  for (int i = 1; i < arr.size(); ++i)
    sum.push_back(sum.back() + arr[i].second);
  long long res = 1;
  for (int lcm = 2; lcm <= arr.back().first; ++lcm) {
    long long currRes = 1;
    for (int ind = 1; ind < divisors[lcm].size(); ++ind) {
      vector<pair<int, int> >::iterator fin = lower_bound(
          arr.begin(), arr.end(), pair<int, int>(divisors[lcm][ind] - 1, kInf));
      vector<pair<int, int> >::iterator st = lower_bound(
          arr.begin(), arr.end(), pair<int, int>(divisors[lcm][ind - 1], 0));
      int s = (int)(st - arr.begin());
      int f = (int)(fin - arr.begin()) - 1;
      currRes = (currRes * Power(ind, RMQ(s, f))) % kMod;
    }
    vector<pair<int, int> >::iterator fin =
        lower_bound(arr.begin(), arr.end(), pair<int, int>(kInf, kInf));
    vector<pair<int, int> >::iterator st = lower_bound(
        arr.begin(), arr.end(), pair<int, int>(divisors[lcm].back(), 0));
    int s = (int)(st - arr.begin());
    int f = (int)(fin - arr.begin()) - 1;
    int cnt = divisors[lcm].size();
    long long pow =
        (Power(cnt, RMQ(s, f)) - Power(cnt - 1, RMQ(s, f)) + kMod) % kMod;
    res = (res + currRes * pow) % kMod;
  }
  cout << res;
  return 0;
}
