#include <bits/stdc++.h>
long long A[2005], F[2005][2005], U[2005], N, X, Y;
using namespace std;
int main() {
  F[0][0] = 1;
  for (int a = 1; a < 2005; a++) {
    F[a][0] = (F[a - 1][0] * a) % 1000000007;
    F[a][1] = ((a - 1) * F[a - 1][0]) % 1000000007;
    for (int b = 2; b < a + 1; b++)
      F[a][b] =
          ((b - 1) * F[a - 1][b - 2] + (a - b) * F[a - 1][b - 1]) % 1000000007;
  }
  cin >> N;
  for (int i = 1; i < N + 1; i++) {
    cin >> A[i];
    U[A[i]] = A[i] > 0;
  }
  for (int i = 1; i < N + 1; i++)
    if (A[i] < 1) X++, Y += !U[i];
  cout << F[X][Y];
}
