#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
long long getPow(int base, int expo) {
  if (expo == 0) {
    return 1;
  }
  long long tmp = getPow(base, (expo >> 1));
  tmp *= tmp;
  if (tmp >= 1000000007) {
    tmp %= 1000000007;
  }
  if (expo & 1) {
    tmp *= base;
  }
  if (tmp >= 1000000007) {
    tmp %= 1000000007;
  }
  return tmp;
}
int main() {
  scanf("%d", &n);
  int mmax = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mmax = max(mmax, a[i]);
  }
  sort(a, a + n);
  long long res = 0;
  for (int i = 1; i <= mmax; i++) {
    vector<int> g;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        g.push_back(j);
        if (j != i / j) {
          g.push_back(i / j);
        }
      }
    }
    g.push_back(1);
    if (i != 1) {
      g.push_back(i);
    }
    g.push_back(mmax + 1);
    sort(g.begin(), g.end());
    long long tmp = 1;
    for (int j = 0; j < g.size() - 1; j++) {
      int *p1 = lower_bound(a, a + n, g[j]);
      int *p2 = lower_bound(a, a + n, g[j + 1]);
      if (j != g.size() - 2) {
        tmp *= getPow(j + 1, p2 - p1);
      } else {
        tmp *= ((getPow(j + 1, p2 - p1) - getPow(j, p2 - p1) + 1000000007) %
                1000000007);
      }
      if (tmp >= 1000000007) {
        tmp %= 1000000007;
      }
    }
    res += tmp;
    if (res >= 1000000007) {
      res %= 1000000007;
    }
  }
  cout << res << endl;
  return 0;
}
