func_code_string: #include <bits/stdc++.h>   using namespace std;   long long f[500500], fact[500500];   int C[2222][2222], used[500500], can[500500], a[500500];   int n, t, u;   int main() {     scanf( %d , &n);     for (int i = 0; i <= n; i++)       for (int j = 0; j <= i; j++)         if ((j == 0) || (j == i))           C[i][j] = 1;         else {           C[i][j] = C[i - 1][j] + C[i - 1][j - 1];           if (C[i][j] >= 1000000007) C[i][j] -= 1000000007;         }     fact[0] = 1;     for (int i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i) % 1000000007;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; i < n; i++)       if (a[i] > 0) used[a[i]] = 1;     for (int i = 0; i < n; i++)       if (a[i] < 0) can[i] = (!used[i + 1]);     for (int i = 0; i < n; i++) t += can[i];     for (int i = 0; i < n; i++) u += (a[i] < 0);     for (int i = n; i >= 0; i--)       if (i > t)         f[i] = 0;       else if (i == t)         f[i] = fact[u - i];       else {         f[i] = (fact[u - i] * C[t][i]) % 1000000007;         for (int j = i + 1; j <= t; j++) {           int r = (f[j] * C[j][i]) % 1000000007;           f[i] -= r;           if (f[i] < 0) f[i] += 1000000007;         }       }     cout << f[0] << endl;   }   