#include <bits/stdc++.h>
using namespace std;
template <class T>
bool setmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
bool setmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  } else
    return false;
}
const long long MOD = 1000000000 + 7;
const int MAXN = 2010;
int a[MAXN];
int n;
int b[MAXN];
int ra[MAXN], rb[MAXN];
long long f[MAXN][MAXN];
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); ++i) scanf("%d", a + i);
  memset(b, (0xff), sizeof(b));
  for (int i = (int)(1); i <= (int)(n); ++i)
    if (a[i] > 0) b[a[i]] = i;
  ra[0] = rb[0] = 0;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    ra[i] = ra[i - 1];
    if (a[i] < 0) ++ra[i];
    rb[i] = rb[i - 1];
    if (b[i] < 0) ++rb[i];
  }
  memset(f, (0), sizeof(f));
  f[0][0] = 1;
  for (int i = (int)(0); i <= (int)(n - 1); ++i)
    for (int j = (int)(0); j <= (int)(i); ++j) {
      long long v = f[i][j];
      f[i + 1][j] = (f[i + 1][j] + v) % MOD;
      if (a[i + 1] < 0)
        f[i + 1][j + 1] = (f[i + 1][j + 1] + v * (rb[i] - j)) % MOD;
      if (b[i + 1] < 0)
        f[i + 1][j + 1] = (f[i + 1][j + 1] + v * (ra[i] - j)) % MOD;
      if (a[i + 1] < 0 && b[i + 1] < 0)
        f[i + 1][j + 2] =
            (f[i + 1][j + 2] + v * (ra[i] - j) % MOD * (rb[i] - j)) % MOD;
    }
  long long ans = f[n][ra[n]];
  cout << ans << endl;
  return 0;
}
