func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int Comb[2015][2015], Fact[2015], used[2015], a[2015];   int main() {     cin.sync_with_stdio(false);     int n, m = 0, k = 0;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       if (a[i] != -1) used[a[i]] = 1;     }     Fact[0] = 1;     for (int i = 1; i <= n; ++i) {       if (used[i] == 0) {         ++m;         if (a[i] == -1) ++k;       }       Fact[i] = 1LL * Fact[i - 1] * i % MOD;     }     for (int i = 0; i <= n; ++i) {       Comb[i][0] = 1;       for (int j = 1; j <= i; ++j)         Comb[i][j] = (Comb[i - 1][j] + Comb[i - 1][j - 1]) % MOD;     }     int sol = 0;     for (int i = 1; i <= k; ++i) {       int x = (1LL * Comb[k][i] * Fact[m - i]) % MOD;       if (i & 1)         sol = (sol + x) % MOD;       else         sol = (0LL + sol + MOD - x) % MOD;     }     cout << (0LL + Fact[m] + MOD - sol) % MOD;     return 0;   }   