#include <bits/stdc++.h>
using namespace std;
long long int a[2020];
bool alive[2020];
int kaijo[2020];
int dp[2020][2020];
int main() {
  long long int n;
  cin >> n;
  vector<long long int> live;
  for (long long int i = 0; i < ((long long int)(n)); i++) {
    cin >> a[i];
    if (a[i] > 0) {
      live.push_back(a[i]);
      alive[i] = true;
    } else
      alive[i] = false;
  }
  kaijo[1] = 1;
  for (long long int i = (long long int)(2); i < ((long long int)(2010)); i++) {
    kaijo[i] = (kaijo[i - 1] * i) % 1000000007;
  }
  long long int asobi = 0;
  for (long long int i = 0;
       i < ((long long int)(((long long int)(live).size()))); i++) {
    if (!alive[live[i] - 1]) asobi++;
  }
  dp[0][0] = 1;
  dp[1][0] = 0;
  dp[1][1] = 1;
  dp[2][0] = 1;
  dp[2][1] = 1;
  dp[2][2] = 2;
  for (long long int i = (long long int)(3); i < ((long long int)(n + 1));
       i++) {
    dp[i][0] = ((i - 1) * dp[i - 1][1]) % 1000000007;
    for (long long int j = (long long int)(1); j < ((long long int)(i)); j++) {
      dp[i][j] =
          ((i - j - 1) * dp[i - 1][min(j + 1, i - 1)] + j * dp[i - 1][j]) %
          1000000007;
    }
    dp[i][i] = kaijo[i];
  }
  cout << dp[n - ((long long int)(live).size())][asobi] << endl;
  return 0;
}
