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.*;
import java.util.*;

public class CF198 {

    public static void main(String[] args) throws IOException {
        new CF198().run();
    }

    final long MOD = (long)(1e9 + 7.5);

    long [] C;
    long [] f;

    void calc_f(int n) {
        f = new long[n + 1];
        f[0] = 1;
        for(int i = 1; i <= n; ++i)
            f[i] = (f[i - 1] * i) % MOD;
    }

    class gcd_res {
        public long g;
        public long x;
        public long y;
        public gcd_res(long _g, long _x, long _y) {
            g = _g;
            x = _x;
            y = _y;
        }
    }

    gcd_res gcd(long a, long b) {
        if(a == 0)
            return new gcd_res(b, 0, 1);
        gcd_res r = gcd(b % a, a);
        return new gcd_res(r.g, (r.y - b / a * r.x) % MOD, r.x % MOD);
    }

    long rev(long a) {
        gcd_res r = gcd(a, MOD);
        if(r.g != 1)
            a /= 0;
        long res = (long)(r.x % MOD);
        return res < 0 ? res + MOD : res;
    }

    void calc_C(int n) {
        C = new long[n + 1];
        for(int i = 0; i <= n; ++i) {
            C[i] = (f[n] * rev(f[i]) % MOD * rev(f[n - i])) % MOD;
        }
    }

    void solve() throws IOException {
        int n = nextInt();

        boolean[] used_num = new boolean[n + 1];
        boolean[] used_pos = new boolean[n + 1];

        int cnt_free = 0;

        for(int i = 1; i <= n; ++i) {
            int ai = nextInt();
            if(ai != -1)
                used_pos[i] = used_num[ai] = true;
            else
                ++cnt_free;
        }

        int cnt_stay = 0;
        for(int i = 1; i <= n; ++i)
            if(!used_num[i] && !used_pos[i])
                ++cnt_stay;

        calc_f(cnt_free);
        calc_C(cnt_stay);

        int sgn = 1;
        long sum = 0;
        for(int i = 0; i <= cnt_stay; ++i, sgn = -sgn)
            sum = (sum + sgn * C[i] * f[cnt_free - i]) % MOD;

        sum = (sum + MOD) % MOD;
        out.println(sum);
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public String nextToken() throws IOException {
        while(st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }

        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

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

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    void run() throws IOException {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;

        br = new BufferedReader( new InputStreamReader( oj ? System.in : new FileInputStream("input.txt")));
        out = new PrintWriter( oj ? System.out : new FileOutputStream("output.txt"));

        solve();

        out.close();
    }

}