func_code_string: #include <bits/stdc++.h>   using namespace std;   long long dp[2010][2010];   int a[2010];   int p[2010];   bool used[2010];   bool ok[2010];   int main() {     int n;     cin >> n;     dp[0][0] = 1;     int rem = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] != -1) {         used[a[i] - 1] = true;         rem++;       } else         p[i] = i - rem + 1;     }     int cnt = 0;     for (int i = 0; i < n; i++)       if (used[i]) ok[p[i]] = true;     for (int i = 1; i <= n; i++) {       dp[i][0] = dp[i - 1][1] + dp[i - 1][0] * (i - 1);       if (ok[i]) dp[i][0] += dp[i - 1][0];       dp[i][0] %= 1000000007;       for (int j = 1; j <= i; j++) {         dp[i][j] = dp[i - 1][j + 1] * (j + 1) + dp[i - 1][j] * (i - 1 - j);         if (ok[i])           dp[i][j] += dp[i - 1][j];         else           dp[i][j] += dp[i - 1][j - 1];         dp[i][j] %= 1000000007;       }     }     long long ans = 0;     for (int j = 0; j <= cnt; j++) ans = (dp[n - rem][j] + ans) % 1000000007;     cout << ans << endl;   }   