Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sabotage his research work.

The girl finds an important permutation for the research. The permutation contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ n). She replaces some of permutation elements with -1 value as a revenge. 

When Iahub finds out his important permutation is broken, he tries to recover it. The only thing he remembers about the permutation is it didn't have any fixed point. A fixed point for a permutation is an element ak which has value equal to k (ak = k). Your job is to proof to Iahub that trying to recover it is not a good idea. Output the number of permutations which could be originally Iahub's important permutation, modulo 1000000007 (109 + 7).

Input

The first line contains integer n (2 ≤ n ≤ 2000). On the second line, there are n integers, representing Iahub's important permutation after Iahubina replaces some values with -1. 

It's guaranteed that there are no fixed points in the given permutation. Also, the given sequence contains at least two numbers -1 and each positive number occurs in the sequence at most once. It's guaranteed that there is at least one suitable permutation.

Output

Output a single integer, the number of ways Iahub could recover his permutation, modulo 1000000007 (109 + 7).

Examples

Input

5
-1 -1 4 3 -1


Output

2

Note

For the first test example there are two permutations with no fixed points are [2, 5, 4, 3, 1] and [5, 1, 4, 3, 2]. Any other permutation would have at least one fixed point. 
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
void itval(istream_iterator<string> it) {}
template <typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  itval(++it, args...);
}
const long long int MOD = 1e9 + 7;
template <typename T>
inline void print(T x) {
  cout << x << "\n";
}
template <typename T>
inline void printvec(T x) {
  for (auto a : x) cout << a << ' ';
  cout << '\n';
}
struct custom {
  bool operator()(const pair<long long int, long long int> &p1,
                  const pair<long long int, long long int> &p2) const {
    return p1.first < p2.first;
  }
};
long long int get_pow(long long int a, long long int b, long long int M = MOD) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % M;
    a = (a * a) % M;
    b >>= 1;
  }
  return res;
}
const long long int N = 7000 + 5, inf = 2e18;
long long int fact[N];
long long int ifact[N];
void pre() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = (fact[i - 1] * i) % MOD;
  ifact[N - 1] = get_pow(fact[N - 1], MOD - 2);
  for (int i = N - 2; i >= 0; i--) ifact[i] = (ifact[i + 1] * (i + 1)) % MOD;
}
long long int ncr(long long int n, long long int r) {
  if (r > n) return 0;
  long long int res = (fact[n] * ifact[r]) % MOD;
  res = (res * ifact[n - r]) % MOD;
  return res;
}
bool have[N];
void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (long long int i = (long long int)0; i < (long long int)(n); i++) {
    cin >> v[i];
    if (v[i] != -1) {
      v[i]--;
      have[v[i]] = 1;
    }
  }
  long long int temp = 0, ans = 0, tot = 0;
  for (long long int i = (long long int)0; i < (long long int)(n); i++) {
    if (!have[i]) tot++;
    if (!have[i] && v[i] == -1) temp++;
  }
  ans = fact[tot];
  for (long long int i = (long long int)1; i < (long long int)(temp + 1); i++) {
    long long int ways = (ncr(temp, i) * fact[tot - i]) % MOD, p = 1;
    if (i & 1) p = -1;
    ans += (p * ways) % MOD;
    ans %= MOD;
  }
  if (ans < 0) ans += MOD;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  clock_t z = clock();
  pre();
  for (long long int tes = (long long int)0; tes < (long long int)(test);
       tes++) {
    solve();
  }
  fprintf(stderr, "Total Time:%.4f\n", (double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
  return 0;
}
