# include # include #include # include #include #include #include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include #include #include #include #include #include #include //#include using namespace std; using LL = long long; using ULL = unsigned long long; long long MOD = 1000000000 + 7;//998244353; constexpr long long INF = numeric_limits::max() / 2; const double PI = acos(-1); #define fir first #define sec second #define thi third #define debug(x) cerr<<#x<<": "< Pll; typedef pair> Ppll; typedef pair>> Pbll; typedef pair>> Pvll; typedef pair Vec2; struct Tll { LL first, second, third; }; struct Fll { LL first, second, third, fourd; }; typedef pair Ptll; #define rep(i,rept) for(LL i=0;i=0;i--) void YN(bool f) { if (f) cout << "YES" << endl; else cout << "NO" << endl; } void yn(bool f) { if (f) cout << "Yes" << endl; else cout << "No" << endl; } struct Edge { LL to, cost; }; struct edge { LL from, to, cost; }; vector>g; vectoredges; vectorv; mapma; setst; LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000], dp[1000100]; string str, ss; bool f; char c; int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } }; LL gcd(LL a, LL b) { if (a < b) gcd(b, a); LL r; while ((r = a % b)) { a = b; b = r; } return b; } struct Combination { int mod; vector< int64_t > mfact, rfact; Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod) { mfact[0] = 1; for (int i = 1; i < mfact.size(); i++) { mfact[i] = mfact[i - 1] * i % mod; } rfact[sz] = inv(mfact[sz]); for (int i = sz - 1; i >= 0; i--) { rfact[i] = rfact[i + 1] * (i + 1) % mod; } } int64_t fact(int k) const { return (mfact[k]); } int64_t pow(int64_t x, int64_t n = MOD - 2) const { int64_t ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return (ret); } int64_t inv(int64_t x) const { return (pow(x, mod - 2)); } int64_t P(int n, int r) const { if (r < 0 || n < r) return (0); return (mfact[n] * rfact[n - r] % mod); } int64_t C(int p, int q) const { if (q < 0 || p < q) return (0); return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod); } int64_t H(int n, int r) const { if (n < 0 || r < 0) return (0); return (r == 0 ? 1 : C(n + r - 1, r)); } }; Combination comb(1000010, MOD); int main() { cin >> n; LL gcd_=-1; rep(i, n) { cin >> a[i]; sum += a[i]; if (gcd_ == -1) { gcd_ = a[i]; } else gcd_ = gcd(gcd_, a[i]); } for (int i = 1; i <= sum; i++) { if (gcd_%i == 0) { LL num = sum / i; cnt = 1; rep(j, n) { cnt *= comb.C(num, a[j] / i); num -= a[j] / i; cnt %= MOD; } dp[i] = cnt; } } for (int i = sum; i >=1; i--) { for (int j = 2; j*i <= sum; j++) { dp[i] -= dp[j*i] * (j); dp[i] += MOD; dp[i] %= MOD; } dp[i] *= comb.pow(sum / i); dp[i] %= MOD; ans += (dp[i]); ans %= MOD; } cout << ans << endl; return 0; }