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 Rust (1.15.1) (judge verdict: Accepted)

#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

struct Comb {
    div: usize,
    g1: Vec<usize>,
    g2: Vec<usize>,
}
impl Comb {
#[allow(dead_code)]
    fn new(nmax: usize) -> Self {
        let mut g1 = vec![1; nmax + 1];
        let mut g2 = vec![1; nmax + 1];
        let mut inv = vec![0; nmax + 1];
        inv[1] = 1;
        let div = 1000000007;
        for i in 2..(nmax + 1) {
            g1[i] = g1[i - 1] * i % div;
            inv[i] = div - (inv[div % i] * (div / i)) % div;
            g2[i] = (g2[i - 1] * inv[i]) % div;
        }
        Comb {
            div: div,
            g1: g1,
            g2: g2,
        }
    }
#[allow(dead_code)]
    fn compute(&self, n: usize, k: usize) -> usize {
        (((self.g1[n] * self.g2[k]) % self.div) * self.g2[n - k]) % self.div
    }
#[allow(dead_code)]
    fn compute_dupc(&self, n: usize, k: usize) -> usize {
        self.compute(n + k - 1, n - 1)
    }
#[allow(dead_code)]
    fn compuute_perm(&self, n: usize, k: usize) -> usize {
        (self.g1[n] * self.g2[n - k]) % self.div
    }
}

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
struct ModInt {
    value: usize,
}
impl ModInt {
    fn new(value: usize) -> Self {
        ModInt {
            value: value % Self::modulo(),
        }
    }
    fn value(&self) -> usize {
        self.value
    }
    fn modulo() -> usize {
        1_000_000_007
    }
}
impl From<usize> for ModInt {
    fn from(value: usize) -> Self {
        ModInt { value: value }
    }
}
impl std::ops::Add for ModInt {
    type Output = Self;
    fn add(self, other: Self) -> Self {
        let mut value = self.value + other.value;
        if value > Self::modulo() {
            value -= Self::modulo();
        }
        ModInt { value: value }
    }
}
impl std::ops::Sub for ModInt {
    type Output = Self;
    fn sub(self, other: Self) -> Self {
        let mut value = self.value;
        if value < other.value {
            value += Self::modulo();
        }
        value -= other.value;
        ModInt { value: value }
    }
}
impl std::ops::Mul for ModInt {
    type Output = Self;
    fn mul(self, other: Self) -> Self {
        let value = self.value * other.value % Self::modulo();
        ModInt { value: value }
    }
}
impl std::ops::Div for ModInt {
    type Output = Self;
    fn div(self, other: Self) -> Self {
        let mut exp = Self::modulo() - 2;
        let mut value = self.value;
        let mut ovalue = other.value;
        while exp > 0 {
            if exp % 2 == 1 {
                value = value * ovalue % Self::modulo();
            }
            ovalue = ovalue * ovalue % Self::modulo();
            exp /= 2;
        }
        ModInt { value: value }
    }
}
impl std::fmt::Debug for ModInt {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.value)
    }
}
impl std::fmt::Display for ModInt {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.value)
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!([usize]);

    let mut appeared = vec![false; n+1];
    let mut num = 0;
    for i in 0..n {
        if appeared[a[i]] {
            num = a[i];
        }
        appeared[a[i]] = true;
    }
    let mut left = 0;
    let mut right = 0;
    let mut already = false;
    for i in 0..n+1 {
        if a[i] == num {
            if already {
                right = n - i;
                break;
            } else {
                already = true;
                left = i;
            }
        }
    }
    println!("{}", n);
    if n == 1 {
        println!("1");
        return;
    }


    let comb = Comb::new(n+1);
    for i in 2..left+right+2 {
        println!("{}", ModInt::new(comb.compute(n+1,i))-ModInt::new(comb.compute(left+right, i-1)));
    }
    for i in left+right+2..n+2 {
        println!("{}", comb.compute(n+1, i));
    }
}