#include <bits/stdc++.h>
using namespace std;
vector<int> fac[100001];
int a[100001];
void pre() {
  for (int i = 1; i < 100001; i++)
    for (int j = i; j < 100001; j += i) fac[j].push_back(i);
}
int powx(long long int a, int n) {
  long long int ans = 1;
  while (n > 0) {
    if (n & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    n >>= 1;
  }
  return ans;
}
int main() {
  pre();
  int n, l, cnt;
  long long int num, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 1; i < 100001; i++) {
    num = 1;
    l = fac[i].size();
    for (int j = 0; j < l - 1; j++)
      num = (num * powx(j + 1, lower_bound(a, a + n, fac[i][j + 1]) -
                                   lower_bound(a, a + n, fac[i][j]))) %
            1000000007;
    if ((cnt = (a + n) - lower_bound(a, a + n, fac[i][l - 1])) != 0) {
      num = (num *
             ((powx(l, cnt) - powx(l - 1, cnt) + 1000000007) % 1000000007)) %
            1000000007;
      ans = (ans + num) % 1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}
