Problem:
Score : 600 points

Problem Statement

You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.
It is known that each of the n integers 1,...,n appears at least once in this sequence.

For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.

Notes

If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.

A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.

Constraints

1 \leq n \leq 10^5

1 \leq a_i \leq n

Each of the integers 1,...,n appears in the sequence.

n and a_i are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_{n+1}

Output

Print n+1 lines.
The k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.

Sample Input 1

3
1 2 1 3

Sample Output 1

3
5
4
1

There are three subsequences with length 1: 1 and 2 and 3.

There are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.

There are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.

There is one subsequence with length 4: 1,2,1,3.

Sample Input 2

1
1 1

Sample Output 2

1
1

There is one subsequence with length 1: 1.

There is one subsequence with length 2: 1,1.

Sample Input 3

32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9

Sample Output 3

32
525
5453
40919
237336
1107568
4272048
13884156
38567100
92561040
193536720
354817320
573166440
818809200
37158313
166803103
166803103
37158313
818809200
573166440
354817320
193536720
92561040
38567100
13884156
4272048
1107568
237336
40920
5456
528
33
1

Be sure to print the numbers modulo 10^9+7.

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
    static int mod=1_000_000_007;
    static long factorial(int n) {
        long tmp = 1;
        for (int i=n;i>0;i--) {
            tmp = (tmp*i) % mod;
        }
        return tmp;
    }
    static long pow(long a,int n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }
    static long modinv(long n) {
        return pow(n, mod-2);
    }
static long nCr(int n, int r) {
    if(n<0 || r<0 || n<r)return 0;
    return factorial(n) * modinv(factorial(n-r)) % mod * modinv(factorial(r)) % mod;
}
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int n = in.nextInt();
        int[] a = new int[n+1];
        int[] cnt = new int[n];
        int index=-1;
        for (int i=0;i<n+1;i++) {
            a[i] = in.nextInt();
            cnt[a[i]-1]++;
            if (cnt[a[i]-1]==2) {
                index=a[i]-1;
            }
        }
        int[] index_array = new int[2];
        int l=0;
        for (int i=0;i<n+1;i++) {
            if (a[i]-1==index) {
                index_array[l]=i;
                l++;
            }
        }
        long[] n1_C_i = new long[n+2];
        n1_C_i[0]=1;
        for (int i=0;i<n+1;i++) {
            n1_C_i[i+1] = n1_C_i[i] * (long)(n+1-i)%mod*modinv(i+1)%mod;
        }

        // long[] bunshi_1 = new long[n+2];
        // long[] bunbo_1 = new long[n+2];
        // bunshi_1[0]=1;
        // bunbo_1[0]=1;
        // for (int i=0;i<n+1;i++) {
        //     bunshi_1[i+1] = bunshi_1[i]*(n+1-i)%mod;
        //     bunbo_1[i+1] = bunbo_1[i]*(i+1)%mod;
        // }
        // long[] bunshi_2 = new long[index_array[0]+(n-index_array[1])+1];
        // long[] bunbo_2 = new long[index_array[0]+(n-index_array[1])+1];
        // bunshi_2[0]=1;
        // bunbo_2[0]=1;
        // for (int i=0;i<index_array[0]+(n-index_array[1]);i++) {
        //     bunshi_2[i+1] = bunshi_2[i]*(index_array[0]+(n-index_array[1])-i)%mod;
        //     bunbo_2[i+1] = bunbo_2[i]*(i+1)%mod;
        // }

        long[] n2_C_i = new long[index_array[0]+(n-index_array[1])+1];
        n2_C_i[0]=1;
        for (int i=0;i<index_array[0]+(n-index_array[1]);i++) {
            n2_C_i[i+1] = n2_C_i[i] * (long)(index_array[0]+(n-index_array[1])-i)%mod*modinv(i+1)%mod;
        }
        // System.out.println(Arrays.toString(n2_C_i));
        // System.out.println(Arrays.toString(bunshi_1));
        // System.out.println(Arrays.toString(bunbo_1));
        // System.out.println(Arrays.toString(bunshi_2));
        // System.out.println(Arrays.toString(bunbo_2));


        for (int i=1;i<=n+1;i++) {
            if (index_array[0]+(n-index_array[1])<i-1) {
                // out.println(nCr(n+1, i));
                out.println(n1_C_i[i]);
                // out.println(bunshi_1[i]*modinv(bunbo_1[i])%mod);
            } else {
                // out.println(nCr(n+1, i)-nCr(index_array[0]+(n-index_array[1]), i-1));
                out.println(n1_C_i[i]-n2_C_i[i-1]);
                // out.println(bunshi_1[i]*modinv(bunbo_1[i])%mod-bunshi_2[i-1]*modinv(bunbo_2[i-1])%mod);
            }
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}