#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cassert>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
static const int P = 1000000007;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i)

//v4
int cond = 1;
string to_string(char c){return'\''+string(1,c)+'\'';}
string to_string(const string&s){return'"'+s+'"';}
string to_string(const char*s){return to_string((string)s);}
string to_string(bool b){return(b?"true":"false");}
string to_string(std::vector<bool>::reference&r){return to_string((bool)r);}
template<typename A,typename B>string to_string(const pair<A,B>&p){return"("+to_string(p.first)+", "+to_string(p.second)+")";}
template<typename A>string to_string(A v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x);}r+="}";return r;}
template<typename A,typename B>string to_string(map<A,B>v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x.first)+" -> "+to_string(x.second);}r+="}";return r;}
void __db(int i,const vector<string>&s){cerr<<endl;}
template<typename T,typename... A>void __db(int i,const vector<string>&s,T t,A... a){if(i)cerr<<", ";cerr<<s[i]<<" = "<<to_string(t);__db(i+1,s,a...);}
string __cl(string s){while(!s.empty()&&s[0]==' ')s.erase(0,1);while(!s.empty()&&s.back()==' ')s.pop_back();return s;}
vector<string>__vars(string s){vector<string>r;s+=",";string n="";int d=0;for(auto x:s)if(x==','&&d==0){if(!n.empty())r.push_back(__cl(n));n="";}else{n+=x;if(x=='('||x=='[')d++;else if(x==')'||x==']')d--;}return r;}
#define DB(...){if(cond){cerr<<"Line:"<<__LINE__<<" ";__db(0,__vars(#__VA_ARGS__),__VA_ARGS__);}}

class PrimeProvider {
 public:
  PrimeProvider(int n) : pr(n + 13, true) {
    pr[0] = pr[1] = false;
    pr[2] = true;
    FOR(i, 2, n) if (pr[i]) {
      int j = 2 * i;
      while (j <= n) {
        pr[j] = false;
        j += i;
      }
    }
    FOR(i, 1, n) if (pr[i]) {
      primes.push_back(i);
    }
  }

  unordered_map<int, int> split(int n) {
    unordered_map<int, int> v;
    int sq = sqrt(n);
    int i = 0;
    while (i < primes.size() && primes[i] <= sq) {
      while (n % primes[i] == 0) {
        n /= primes[i];
        v[primes[i]]++;
      }
      ++i;
    }
    if (n != 1) {
      v[n]++;
    }
    return v;
  }

  bool isprime(int n) {
    if (n == 1) {
      return false;
    }
    int sq = sqrt(n);
    if (sq * sq == n) {
      return false;
    }
    int i = 0;
    while (i < primes.size() && primes[i] <= sq) {
      if (n % primes[i] == 0) {
        return false;
      }
      ++i;
    }
    return true;
  }

  vector<bool> pr;
  vector<int> primes;
};

int _ExpMod(LL a, int b) {
  LL p = 1;
  while(b > 0) {
    if (b&1) {
      p = (a * p) % P;
    }
    a = (a * a) % P;
    b /= 2;
  }
  return p;
}



int comp(unordered_map<int, int>& nwd, unordered_map<int, int>& tmp) {
  LL res = 1;
  for (auto& x : nwd) {
    int val = x.second;
    auto xx = tmp.find(x.first);
    if (xx != tmp.end()) {
      val -= xx->second;
    }
    res = (res * _ExpMod(x.first, val)) % P;
  }
  return res;
}

int main() {
  int n;
  scanf("%d", &n);
  PrimeProvider pp(1000123);
  unordered_map<int, int> nwd;
  vector<unordered_map<int, int>> r;
  REP(i, n) {
    int x;
    scanf("%d", &x);
    auto v = pp.split(x);
    for (auto x : v) {
      nwd[x.first] = max(nwd[x.first], x.second);
    }
    r.push_back(v);
  }
  int solution = 0;
  for (auto& x : r) {
    int res = comp(nwd, x);
    solution = (solution + res) % P;
  }
  printf("%d\n", solution);
  return 0;
}

Measured memory_bytes: 3764