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. 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class C {

	private static final long MOD = (long) (1e9 + 7.1);
	
	private void solve() throws IOException {
		int n = nextInt();
		int[] a = new int[n];
		
		int removed = 0;
		for (int i = 0; i < n; i++) {
			a[i] = nextInt() - 1;
			if (a[i] == -2) {
				removed++;
			}
		}
		
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			if (a[i] != -2) {
				b[a[i]] = 1;
			}
		}
		
		int k = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == -2 && b[i] == 0) {
				k++;
			}
		}
		
		int m = removed;
		
		long[][] d = new long[k + 1][m + 1];
		long[] fact = new long[m + 1];
		fact[0] = 1;
		for (int i = 1; i <= m; i++) {
			fact[i] = (fact[i - 1] * i) % MOD;
		}
		
		for (int i = 1; i <= m; i++) {
			d[0][i] = fact[i];
		}
		if (k >= 1) {
			for (int i = 2; i <= m; i++) {
				d[1][i] = ((i - 1) * d[0][i - 1]) % MOD;
			}
		}
		for (int i = 2; i <= k; i++) {
			for (int j = i; j <= m; j++) {
				long t1 = ((i - 1) * d[i - 2][j - 1]) % MOD;
				long t2 = ((j - i) * d[i - 1][j - 1]) % MOD;
				d[i][j] = (t1 + t2) % MOD;
			}
		}
		
		println(d[k][m]);
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	private int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	private double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private void print(Object o) {
		writer.print(o);
	}

	private void println(Object o) {
		writer.println(o);
	}

	private void printf(String format, Object... o) {
		writer.printf(format, o);
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		new C().run();
		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	private void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(13);
		}
	}
}