#include <bits/stdc++.h>
using namespace std;
long long modpow(long long x, long long y) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans *= x;
    y >>= 1;
    x *= x;
    ans %= 1000000007;
    x %= 1000000007;
  }
  return ans;
}
long long moddiv(long long x) { return modpow(x, 1000000007 - 2); }
int main() {
  long long N, a, cc = 0;
  cin >> N;
  bool alr[2001];
  for (int i = 0; i < N; i++) alr[i] = 0;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> a;
    a--;
    A[i] = a;
    if (a < 0)
      cc++;
    else
      alr[a] = 1;
  }
  long long cnt = 0;
  for (int i = 0; i < N; i++) {
    if (!alr[i] && A[i] < 0) {
      cnt++;
    }
  }
  long long excl[2001];
  excl[0] = 1;
  for (long long i = 1; i <= cc; i++) {
    excl[i] = excl[i - 1] * i;
    excl[i] %= 1000000007;
  }
  long long comb[2001];
  comb[0] = 1;
  for (long long i = 1; i <= cc; i++) {
    comb[i] = comb[i - 1] * (cnt - i + 1);
    comb[i] %= 1000000007;
    comb[i] *= moddiv(i);
    comb[i] %= 1000000007;
  }
  long long ans = excl[cc];
  for (long long i = 1; i <= cnt; i++) {
    if (i & 1)
      ans -= comb[i] * excl[cc - i];
    else
      ans += comb[i] * excl[cc - i];
    ans %= 1000000007;
    if (ans < 0) ans += 1000000007;
  }
  cout << ans << endl;
}
