#include <bits/stdc++.h>
static long long fact[2010];
static int N, in[2010], m[2010], K = 0, R = 0;
inline long long nCr(int n, int r) {
  long long b = (fact[r] * fact[n - r]) % 1000000007;
  long long e = 1000000007 - 2, x = 1;
  while (e) {
    if (e % 2) x = (x * b) % 1000000007;
    e /= 2;
    b = (b * b) % 1000000007;
  }
  long long RET = (fact[n] * x) % 1000000007;
  return RET;
}
int main() {
  scanf("%d", &N);
  fact[0] = 1;
  for (int i = 1; i <= 2000; ++i) fact[i] = (i * fact[i - 1]) % 1000000007;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &in[i]);
    if (in[i] > 0) {
      m[in[i]] = 1;
      R++;
    }
  }
  for (int i = 1; i <= N; ++i) {
    if (!m[i] && in[i] < 0) K++;
  }
  N -= R;
  long long ANS = fact[N];
  for (int i = 1; i <= K; ++i) {
    if (i % 2)
      ANS = (ANS - (nCr(K, i) * fact[N - i]) + 1000000007) % 1000000007;
    else
      ANS = (ANS + (nCr(K, i) * fact[N - i])) % 1000000007;
  }
  std::cout << ANS << '\n';
}
