#include <bits/stdc++.h>
using namespace std;
void RD(int &x) { scanf("%d", &x); }
void RD(long long &x) { scanf("%I64d", &x); }
void RD(unsigned int &x) { scanf("%u", &x); }
void RD(double &x) { scanf("%lf", &x); }
void RD(int &x, int &y) { scanf("d", &x, &y); }
void RD(long long &x, long long &y) { scanf("I64d", &x, &y); }
void RD(unsigned int &x, unsigned int &y) { scanf("u", &x, &y); }
void RD(double &x, double &y) { scanf("lf", &x, &y); }
void RD(int &x, int &y, int &z) { scanf("d%d", &x, &y, &z); }
void RD(long long &x, long long &y, long long &z) {
  scanf("I64d%I64d", &x, &y, &z);
}
void RD(unsigned int &x, unsigned int &y, unsigned int &z) {
  scanf("u%u", &x, &y, &z);
}
void RD(double &x, double &y, double &z) { scanf("lf%lf", &x, &y, &z); }
void RD(char &x) { x = getchar(); }
void RD(char *s) { scanf("%s", s); }
void RD(string &s) { cin >> s; }
void PR(int x) { printf("%d\n", x); }
void PR(long long x) { printf("%I64d\n", x); }
void PR(unsigned int x) { printf("%u\n", x); }
void PR(double x) { printf("%.6lf\n", x); }
void PR(char x) { printf("%c\n", x); }
void PR(char *x) { printf("%s\n", x); }
void PR(string x) { cout << x << endl; }
int a[100006];
vector<int> b[100006];
long long f[100006];
int _a;
int cnt[100006];
void init(int _max) {
  for (int i = 0; i <= _max; i++) b[i].clear();
  int i = 1;
  while (i <= _max) {
    int j = i;
    while (j <= _max) {
      b[j].push_back(i);
      j = j + i;
    }
    i++;
  }
}
long long quick(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    _a = -1;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      cnt[a[i]]++;
      _a = ((_a) > (a[i]) ? (_a) : (a[i]));
    }
    init(_a);
    for (int i = _a; i >= 1; i--) cnt[i] = cnt[i] + cnt[i + 1];
    long long ans = 1, tmp;
    for (int i = 2; i <= _a; i++) {
      int size = b[i].size();
      tmp = ((quick(size, cnt[b[i][size - 1]]) -
              quick(size - 1, cnt[b[i][size - 1]])) %
                 1000000007 +
             1000000007) %
            1000000007;
      for (int j = 0; j < size - 1; j++) {
        tmp = tmp * quick(j + 1, cnt[b[i][j]] - cnt[b[i][j + 1]]) % 1000000007;
      }
      ans += tmp % 1000000007;
    }
    printf("%I64d\n", ans % 1000000007);
  }
  return 0;
}
