#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define endl '\n' #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end()) typedef long long ll; typedef long double ld; typedef pair P; typedef complex comp; typedef vector< vector > matrix; struct pairhash { public: template size_t operator()(const pair &x) const { size_t seed = hash()(x.first); return hash()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2); } }; const int inf = 1e9 + 9; const ll mod = 1e9 + 7; const double eps = 1e-8; const double pi = acos(-1); int k; ll c[100100]; ll sum = 0; ll d[1010]; ll mod_pow(ll x, ll n) { ll res = 1; while (n > 0) { if (n & 1) res = (res * x) % mod; x = (x * x) % mod; n >>= 1; } return res; } ll mod_inverse(ll x) { return mod_pow(x, mod-2); } const int max_n = 1000100; ll fact[max_n]; ll fact_inv[max_n]; void calc_fact() { fact[0] = 1; for (ll i = 1; i < max_n; i++) fact[i] = (fact[i-1] * i) % mod; fact_inv[max_n-1] = mod_inverse(fact[max_n-1]); for (ll i = max_n-2; i >= 0; i--) fact_inv[i] = (fact_inv[i+1] * (i+1)) % mod; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a%b); } ll solve() { for (int i = 0; i < k; i++) sum += c[i]; calc_fact(); for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { d[i] = fact[sum/i]; for (int j = 0; j < k; j++) { if (c[j] % i) { d[i] = 0; break; } else { d[i] = d[i] * fact_inv[c[j]/i] % mod; } } } } swap(d[0], d[1]); ll res = d[0]; for (int i = 1; i < sum; i++) { res = (res + d[gcd(sum, i)]) % mod; } return res * mod_inverse(sum) % mod; } void input() { cin >> k; for (int i = 0; i < k; i++) cin >> c[i]; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); input(); cout << solve() << endl; }