#include using namespace std; #define int long long #define pb emplace_back #define sz(v) (int)(v.size()) #define all(v) (v.begin(),v.end()) const int32_t MAX = 510000; const int32_t M=1e9+7; int fac[MAX], finv[MAX], inv[MAX]; void cominit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % M; inv[i] = M - inv[M%i] * (M / i) % M; finv[i] = finv[i - 1] * inv[i] % M; } } int COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % M) % M; } int FINV(int n){ if (n < 0) return 0; return finv[n]; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); cominit(); int n; cin >> n; vector v(n); for(int i = 0;i> v[i]; int dp[n]; dp[0] = 1; for(int i = 1;i<=n;i++){ dp[i] = (dp[i-1] * (n - i))/i % M; } // dp stores the value of ncr from r = 0 to r = n int ans = 0; for(int i = 0;i