func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, i;   long long a[2019];   int b[2100], ok[2100];   const int MAXN = 2000;   long long C[MAXN + 1][MAXN + 1];   void init() {     int i, j;     for (i = 0; i <= MAXN; ++i) {       C[0][i] = 0;       C[i][0] = 1;     }     for (i = 1; i <= MAXN; ++i) {       for (j = 1; j <= MAXN; ++j)         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % 1000000007;     }   }   int main() {     init();     int T, j;     a[1] = 0;     a[2] = 1;     for (i = 3; i <= 2001; i++)       a[i] = (i - 1) * ((a[i - 1] + a[i - 2])) % 1000000007;     cin >> n;     int p = 0;     int flag = 1;     for (i = 1; i <= n; i++) {       int x;       cin >> x;       if (x != -1) {         p++;         ok[i] = 1;       }       if (x != -1) b[x] = 1;     }     if (n == 2) {       cout << 1 << endl;       return 0;     }     long long ans = 1;     for (i = 2; i <= n - p; i++) ans = ans * i % 1000000007;     long long t = 0, r = n - p;     for (i = 1; i <= n; i++)       if (ok[i] == 0 && b[i] == 0) t++;     int f = 1;     for (i = 1; i <= t; i++) {       long long tmp = C[t][i] % 1000000007;       for (j = 2; j <= n - p - i; j++) tmp = tmp * j % 1000000007;       ans -= f * tmp % 1000000007;       ans %= 1000000007;       ans += 1000000007;       ans %= 1000000007;       f = -f;     }     cout << ans << endl;   }   