#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
int mul(int a, int b) { return (long long)a * b % MOD; }
int sub(int a, int b) { return a < b ? a - b + MOD : a - b; }
int powMod(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = mul(a, a))
    if (b & 1) res = mul(res, a);
  return res;
}
const int MAXN = 100001;
int n, a[MAXN], way[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int res = 0;
  for (int i = (1); i < (a[n - 1] + 1); i++) {
    vector<int> divisor;
    for (int j = 1; j <= i / j; j++) {
      if (i % j) continue;
      divisor.push_back(j);
      divisor.push_back(i / j);
    }
    sort(((divisor).begin()), ((divisor).end()));
    (divisor).erase(unique(((divisor).begin()), ((divisor).end())),
                    ((divisor).end()));
    int lastPosition = n;
    way[i] = 1;
    for (int j = ((int)(divisor).size()) - 1; j >= 0; j--) {
      int position = lower_bound(a, a + lastPosition, divisor[j]) - a;
      if (j + 1 == ((int)(divisor).size())) {
        way[i] = mul(way[i], sub(powMod(j + 1, lastPosition - position),
                                 powMod(j, lastPosition - position)));
      } else {
        way[i] = mul(way[i], powMod(j + 1, lastPosition - position));
      }
      lastPosition = position;
    }
    res = add(res, way[i]);
  }
  printf("%d\n", res);
  return 0;
}
