#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> in;
long long _C[2010][2010];
long long fact[2010];
void init() {
  for (int i = 0; i < 2010; ++i) {
    _C[i][0] = _C[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      _C[i][j] = _C[i - 1][j] + _C[i - 1][j - 1];
      if (_C[i][j] >= 1000000007LL) _C[i][j] -= 1000000007LL;
    }
  }
  fact[0] = 1;
  for (int i = 1; i < 2010; ++i) fact[i] = (i * fact[i - 1]) % 1000000007LL;
}
long long C(int el, int kl) {
  if (el < kl) return 0;
  return _C[el][kl];
}
int main() {
  init();
  scanf("%d", &N);
  in.resize(N);
  int s_eq = 0, bez_eq = 0;
  for (int i = 0; i < N; ++i) scanf("%d", &in[i]);
  set<int> avb(in.begin(), in.end());
  for (int i = 0; i < N; ++i) {
    int val = i + 1;
    if (in[i] == -1) {
      if (avb.count(val))
        ++bez_eq;
      else
        ++s_eq;
    }
  }
  long long ans = 0;
  for (int i = 0; i <= s_eq; ++i) {
    long long cur = 0;
    cur = (C(s_eq, i) * fact[s_eq + bez_eq - i]) % 1000000007LL;
    if (i & 1)
      ans = ans - cur;
    else
      ans = ans + cur;
    ans %= 1000000007LL;
  }
  cout << ((ans % 1000000007LL) + 1000000007LL) % 1000000007LL << '\n';
  return 0;
}
