#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> divs_all(int x) {
  vector<vector<int>> res(x + 1);
  for (int i = 1; i <= x; i++) {
    for (int j = 1; j * i <= x; j++) {
      res[i * j].push_back(i);
    }
  }
  return res;
}
long long mod_pow(long long a, long long b, long long mod) {
  long long res = 1, c = a;
  while (b) {
    if (b & 1) res = res * c % mod;
    c = c * c % mod;
    b /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> ta(101010);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ta[a]++;
  }
  int sum = 0;
  for (int i = ta.size() - 1; i >= 0; i--) {
    sum += ta[i];
    ta[i] = sum;
  }
  long long mod = 1000000007;
  long long res = 0;
  vector<vector<int>> divs = divs_all(101010);
  for (int i = 1; i < 101010; i++) {
    int prev = 0;
    long long te1 = 1;
    for (int j = divs[i].size() - 1; j >= 0; j--) {
      int div = divs[i][j];
      int diff = ta[div] - prev;
      te1 = (te1 * mod_pow((j + 1), diff, mod)) % mod;
      prev = ta[div];
    }
    prev = 0;
    long long te2 = 1;
    for (int j = divs[i].size() - 2; j >= 0; j--) {
      int div = divs[i][j];
      int diff = ta[div] - prev;
      te2 = (te2 * mod_pow((j + 1), diff, mod)) % mod;
      prev = ta[div];
    }
    te1 = (te1 - te2 + mod) % mod;
    res = (res + te1) % mod;
  }
  cout << (res + 1) % mod << "\n";
  return 0;
}
