#include <bits/stdc++.h>
using namespace std;
int to[100010 * 12], he[100010], nex[100010 * 12], top;
int tree[100010];
void addy(int u, int n) {
  to[top] = n;
  nex[top] = he[u];
  he[u] = top++;
}
void add(int pos) {
  while (pos < 100010) {
    ++tree[pos];
    pos += pos & (-pos);
  }
}
int query(int pos) {
  int ans = 0;
  while (pos) {
    ans += tree[pos];
    pos -= pos & (-pos);
  }
  return ans;
}
int exp_mod(int a, int p) {
  if (p == 0 || a == 0)
    return 1;
  else if (p == 1)
    return a;
  else {
    long long ans = exp_mod(a, p / 2);
    ans = ans * ans % 1000000007;
    if (p & 1) ans = ans * a % 1000000007;
    return ans;
  }
}
int main() {
  int best = 0, n, tmp;
  long long ans = 0;
  memset(he, -1, sizeof(he));
  for (int i = 1; i < 100010; ++i) addy(i, 100010 - 1);
  for (int i = 100010 - 1; i > 1; --i)
    for (int j = i; j < 100010; j += i) addy(j, i);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &tmp), best = max(best, tmp), add(tmp);
  for (int i = 2; i <= best; ++i) {
    int prev = tree[1], dif;
    long long tans = 1;
    for (int j = he[i], k = 1; j != -1; j = nex[j], ++k) {
      dif = query(to[j] - 1) - prev;
      if (nex[j] != -1)
        tans = tans * exp_mod(k, dif) % 1000000007;
      else
        tans = tans * (exp_mod(k, dif) - exp_mod(k - 1, dif) + 1000000007) %
               1000000007;
      prev += dif;
    }
    ans = (ans + tans) % 1000000007;
  }
  cout << ans + 1;
  return 0;
}
