#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
const int MAX_A = 1e5 + 5;
const int MOD = 1e9 + 7;
int a[MAX_N], DP[MAX_A];
int CalcPower(int x, int y) {
  if (y == 0) {
    return 1;
  } else if (y % 2 == 0) {
    int p = CalcPower(x, y / 2);
    return (1ll * p * p) % MOD;
  } else {
    return (1ll * x * CalcPower(x, y - 1)) % MOD;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    DP[a[i]]++;
  }
  for (int i = 1; i <= a[n - 1]; i++) {
    DP[i] += DP[i - 1];
  }
  int ans = 0;
  for (int i = 1; i <= a[n - 1]; i++) {
    vector<int> divs;
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        divs.push_back(j);
        if (j * j != i) {
          divs.push_back(i / j);
        }
      }
    }
    sort(divs.begin(), divs.end());
    divs.push_back(a[n - 1] + 1);
    int indInA = 0, currAns = 1;
    for (int j = 1; j < divs.size(); j++) {
      int currCnt = DP[divs[j] - 1] - DP[divs[j - 1] - 1];
      if (j == divs.size() - 1) {
        currAns = (1ll * currAns *
                   (1ll * CalcPower(j, currCnt) -
                    1ll * CalcPower(j - 1, currCnt) + MOD)) %
                  MOD;
      } else {
        currAns = (1ll * currAns * 1ll * CalcPower(j, currCnt)) % MOD;
      }
    }
    ans = (1ll * ans + 1ll * currAns) % MOD;
  }
  cout << ans << '\n';
  return 0;
}
