#include <bits/stdc++.h>
const int N = 2005;
const int inf = 1 << 28;
const double eps = 1e-8;
const int mod = 1e9 + 7;
using namespace std;
int n, a[N];
long long dp[N][N];
bool use[N];
int main() {
  while (scanf("%d", &n) > 0) {
    memset(use, 0, sizeof(use));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (~a[i]) use[a[i]] = 1;
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    int cnt = 0, fuck = 0;
    for (int i = 0; i <= n; i++) {
      int j = i - cnt, t = i - fuck;
      if (~a[i + 1]) fuck++;
      if (use[i + 1]) cnt++;
      for (; j >= 0; j--, t--) {
        if (!dp[i][j]) continue;
        if (t < 0) t = 0;
        if (!use[i + 1]) {
          dp[i + 1][j + 1] += dp[i][j];
          dp[i + 1][j + 1] %= mod;
          if (t) {
            dp[i + 1][j] += dp[i][j] * t;
            dp[i + 1][j] %= mod;
            if (a[i + 1] == -1 && j) {
              dp[i + 1][j] += dp[i][j] * j;
              dp[i + 1][j] %= mod;
              dp[i + 1][j - 1] += dp[i][j] * t * j % mod;
              dp[i + 1][j - 1] %= mod;
            }
          } else {
            if (a[i + 1] == -1 && j) {
              dp[i + 1][j] += dp[i][j] * j;
              dp[i + 1][j] %= mod;
            }
          }
        } else {
          dp[i + 1][j] += dp[i][j];
          dp[i + 1][j] %= mod;
          if (a[i + 1] == -1 && j) {
            dp[i + 1][j - 1] += dp[i][j] * j;
            dp[i + 1][j - 1] %= mod;
          }
        }
      }
    }
    printf("%I64d\n", dp[n][0]);
  }
  return 0;
}
