#include <bits/stdc++.h>
using namespace std;
int nr = 1;
int pr[10000];
char p[100000];
vector<int> a[100100];
int n, i, j, cnt;
int v[100100];
int d[129][100100];
long long ax;
long long sol;
int l, mn, res;
void ciur(int n) {
  int i, j;
  for (i = 1; ((i * i) << 1) + (i << 1) <= n; i += 1) {
    if ((p[i >> 3] & (1 << (i & 7))) == 0) {
      for (j = ((i * i) << 1) + (i << 1); (j << 1) + 1 <= n;
           j += (i << 1) + 1) {
        p[j >> 3] |= (1 << (j & 7));
      }
    }
  }
  pr[nr] = 2;
  for (i = 1; 2 * i + 1 <= n; ++i)
    if ((p[i >> 3] & (1 << (i & 7))) == 0) pr[++nr] = 2 * i + 1;
}
void caut(int st, int dr, int x) {
  int m;
  if (st <= dr) {
    m = (st + dr) / 2;
    if (v[m] >= x) {
      if (mn == -1 || mn > m) mn = m;
      caut(st, m - 1, x);
    } else
      caut(m + 1, dr, x);
  }
}
inline int mod(int x) {
  if (x < 0) x = x + 1000000007;
  return x;
}
int main() {
  ciur(400);
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (i = 2; i <= 100000; i++) {
    for (j = i; j <= 100000; j += i) {
      a[j].push_back(i);
      cnt++;
    }
  }
  for (i = 1; i <= 128; i++) {
    d[i][0] = 1;
    for (j = 1; j <= 100000; j++)
      d[i][j] = ((long long)((long long)d[i][j - 1] * i) % 1000000007);
  }
  stable_sort(v + 1, v + n + 1);
  sol = 0;
  res = 1;
  for (i = 2; i <= v[n]; i++) {
    l = n;
    mn = -1;
    caut(1, l, i);
    l = mn;
    sol = mod(d[a[i].size() + 1][n - l + 1] - d[a[i].size()][n - l + 1]);
    for (j = a[i].size() - 2; j >= 0 && l > 1; j--) {
      mn = -1;
      caut(1, l - 1, a[i][j]);
      if (mn == -1) continue;
      sol = ((long long)((long long)sol * d[j + 2][l - mn]) % 1000000007);
      l = mn;
    }
    res = ((long long)((long long)res + sol) % 1000000007);
  }
  printf("%d", res);
  return 0;
}
