func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T Abs(T a) {     return a > 0 ? a : -a;   }   template <typename T>   inline T sqr(T a) {     return a * a;   }   template <typename T>   inline void relaxMin(T &a, T b) {     if (b < a) a = b;   }   template <typename T>   inline void relaxMax(T &a, T b) {     if (b > a) a = b;   }   const int INF = (int)1E9;   const long double EPS = 1E-6;   const long double PI = 3.1415926535897932384626433832795;   int dp[2000][2000];   int mod = 1000000007;   void solve() {     int n;     cin >> n;     int k;     int x = 0, y = 0;     for (int i(0), _bb(n); i < _bb; ++i) {       cin >> k;       if (k == 1)         x++;       else         y++;     }     dp[0][0] = 1;     dp[1][0] = dp[1][1] = 1;     for (int i(2), _bb(1001); i < _bb; ++i) {       dp[i][0] = (dp[i - 1][0] + (i - 1) * 1LL * dp[i - 2][0]) % mod;       for (int j(1), _bb(1001); j < _bb; ++j)         dp[i][j] = (dp[i - 1][j - 1] * 1LL * i) % mod;     }     cout << dp[n][y] << endl;   }   int main() {     srand(0xA1B2C3D4);     solve();     return 0;   }   