func_code_string: #include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   long long die = 0;   const double eps = 1e-8;   const long long mod = 1e9 + 7;   const long long N = 1e6 + 5;   long long n;   long long a[N];   long long x, y;   bool mp[N];   long long fac[N];   long long inv[N];   long long C(long long y, long long i) {     return fac[y] * inv[i] % mod * inv[y - i] % mod;   }   void sol1() {     x = y = 0;     for (long long i = (1); i <= (n); i++)       if (a[i] == -1) {         if (mp[i])           x++;         else           y++;       }     n = x + y;     inv[0] = inv[1] = fac[0] = 1;     for (long long i = (1); i <= (n); i++) fac[i] = fac[i - 1] * i % mod;     for (long long i = (2); i <= (n); i++)       inv[i] = (mod - mod / i) * inv[mod % i] % mod;     for (long long i = (2); i <= (n); i++) (inv[i] *= inv[i - 1]) %= mod;     long long ans = fac[n];     for (long long i = (1); i <= (y); i++)       (ans += ((i & 1) ? -1 : 1) * C(y, i) * fac[n - i] % mod) %= mod;     (ans += mod) %= mod;     printf( %I64d n , ans);   }   void rd() {     n = read();     for (long long i = (1); i <= (n); i++) {       a[i] = read();       if (a[i] != -1) mp[a[i]] = 1;     }     sol1();   }   signed main() { rd(); }   