#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:66777216 )   using namespace std;   const int N = 100007;   int n, a[N], cnt[N];   vector<int> D[N];   long long power(long long a, long long b) {     if (b == 0) {       return 1;     }     if (b & 1) {       return (a * power(a, b - 1)) % 1000000007LL;     }     long long ret = power(a, b >> 1);     return (ret * ret) % 1000000007LL;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     sort(a, a + n);     for (int i = 1; i <= a[n - 1]; ++i) {       for (int j = i; j <= a[n - 1]; j += i) {         D[j].push_back(i);       }     }     long long ans = 0;     for (int m = 1; m <= a[n - 1]; ++m) {       vector<int> &d = D[m];       int nd = (int)(d).size();       for (int i = 0; i < nd; ++i) {         cnt[i] = n - (lower_bound(a, a + n, d[i]) - a);       }       long long cur =           (power(nd, cnt[nd - 1]) - power(nd - 1, cnt[nd - 1]) + 1000000007LL) %           1000000007LL;       for (int i = 0; i < nd - 1; ++i) {         cur = (cur * power(i + 1, cnt[i] - cnt[i + 1])) % 1000000007LL;       }       ans = (ans + cur) % 1000000007LL;     }     printf( %d n , (int)ans);     return 0;   }   