#include <bits/stdc++.h>
const int MOD = 1000000007;
using namespace std;
int N;
int arr[2000];
int restrictions;
bool inArr[2000];
long long fact[2010];
long long C[2010][2010];
int main() {
  scanf("%d", &(N));
  for (int i = (0); i < (N); i++) scanf("%d", &(arr[i]));
  for (int i = (0); i < (N); i++) arr[i]--;
  for (int i = (0); i < (N); i++)
    if (arr[i] >= 0) inArr[arr[i]] = true;
  for (int i = (0); i < (N); i++)
    if (!inArr[i] && arr[i] < 0) restrictions++;
  int tot = 0;
  for (int i = (0); i < (N); i++) tot += arr[i] < 0;
  for (int i = (0); i < (2010); i++)
    for (int j = (0); j < (2010); j++) {
      if (j == 0)
        C[i][j] = 1;
      else if (j > i)
        C[i][j] = 0;
      else
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
    }
  fact[0] = 1;
  for (int i = (1); i < (2010); i++) fact[i] = fact[i - 1] * i % MOD;
  long long ans = 0;
  for (int wrong = 0; wrong <= restrictions; wrong++) {
    long long v = C[restrictions][wrong] * fact[tot - wrong] % MOD;
    if (wrong % 2)
      ans -= v;
    else
      ans += v;
    ans += MOD;
    ans %= MOD;
  }
  printf("%lld\n", ans);
}
