#include using namespace std; using mint = atcoder::modint1000000007; int main(){ ios::sync_with_stdio(false); cin.tie(0); int K, Csum = 0, gcdv = 0; cin >> K; vector C(K), y; for(auto &&v:C){ cin >> v; gcdv = __gcd(gcdv, v); Csum += v; } vector fact(Csum + 1), inv(Csum + 1); fact[0] = 1; for(int i = 1; i <= Csum; i++)fact[i] = i * fact[i - 1]; for(int i = 1; i * i <= gcdv; i++){ if(gcdv % i == 0){ y.push_back(i); if(gcdv / i != i)y.push_back(gcdv / i); } } sort(y.rbegin(), y.rend()); vector calc(y.size()); mint ans; for(int i = 0; i < y.size(); i++){ int d = y[i]; calc[i] = fact[Csum / d - 1]; mint div = fact[C[0] / d - 1]; for(int j = 1; j < K; j++)div *= fact[C[j] / d]; calc[i] /= div; for(int j = 0; j < i; j++){ if(y[j] % y[i] == 0)calc[i] -= calc[j]; } ans += calc[i] / (C[0] / d); } cout << ans.val() << '\n'; }