#include <bits/stdc++.h>   using namespace std;   const int M = 1000000007;   const int N = 100003;   int ld[N];   int a[N];   void sieve() {     for (int i = 2; i * i < N; ++i)       if (ld[i] == 0)         for (int j = i * i; j < N; j += i)           if (ld[j] == 0) ld[j] = i;     for (int i = 2; i < N; ++i)       if (ld[i] == 0) ld[i] = i;   }   vector<int> p;   vector<int> k;   vector<int> d;   void genDivisors(int i, int x) {     if (i == (int)p.size()) {       d.push_back(x);       return;     }     for (int c = 0; c <= k[i]; ++c) {       genDivisors(i + 1, x);       x *= p[i];     }   }   int expMod(int a, int n) {     int res = 1;     while (n > 0) {       if (n & 1) res = (long long)res * a % M;       n >>= 1;       a = (long long)a * a % M;     }     return res;   }   int main() {     sieve();     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , a + i);     sort(a, a + n);     int res = 0;     for (int x = 1; x <= a[n - 1]; ++x) {       p.clear();       k.clear();       d.clear();       int y = x;       while (y > 1) {         int z = ld[y];         p.push_back(ld[y]);         k.push_back(1);         y /= z;         while (y % z == 0) {           y /= z;           ++k.back();         }       }       genDivisors(0, 1);       sort(d.begin(), d.end());       k.clear();       k.resize(d.size());       for (int i = 0; i < (int)d.size(); ++i)         k[i] = n - (lower_bound(a, a + n, d[i]) - a);       y = 1;       for (int i = 0; i < (int)d.size() - 1; ++i) {         k[i] -= k[i + 1];         y = (long long)y * expMod(i + 1, k[i]) % M;       }       int z =           (expMod(d.size(), k.back()) - expMod((int)d.size() - 1, k.back()) + M) %           M;       y = (long long)y * z % M;       res = (res + y) % M;     }     printf( %d n , res);     return 0;   }   