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.



Sample input:
3
1 2 1 3


Sample output:
3
5
4
1

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int,stdin.readline().split()))

MOD = 10**9+7

class Comb:
    def __init__(self, size):
        self.fact = [0 for i in range(size + 1)]
        self.inv_fact = [0 for i in range(size + 1)]
        self.factrical(size)

    def nCr(self, n,r):
        ret = self.fact[n]
        ret *= self.inv_fact[n-r]
        ret %= MOD
        ret *= self.inv_fact[r]
        ret %= MOD
        return ret

    def factrical(self, N):
        self.fact[0] = 1
        self.inv_fact[0] = 1
        for i in range(1,N+1):
            self.fact[i] = i * self.fact[i-1] % MOD
            self.inv_fact[i] = self.inv(self.fact[i]) % MOD

    def powmod(self, a,p):
        if (p==0):
            return 1
        if (p%2==1):
            return a * self.powmod(a,p-1) % MOD
        else:
            c = self.powmod(a,p/2)
            return c * c % MOD

    def inv(self, a):
        return self.powmod(a, MOD-2)

N = ni()
a = na()
c = [-1 for i in range (N)]
index = [-1,-1]

for i, x in enumerate(a):
    if (c[x-1]!=-1):
        index[0] = c[x-1]
        index[1] = i
        break

    c[x-1] = i

co = Comb(N+1)
for i in range(1, N+2):
    ans = co.nCr(N+1,i)
    if ((N-index[1]) + (index[0])>=i-1 ):
        ans -= co.nCr((N-index[1]) + (index[0]),i-1) 
    
    print (ans)

Submission status: Wrong Answer

Solution code:
n,*A=map(int,open(0).read().split());n+=1;f=[1]*-~n;r=f[:];M=10**9+7
for a in A:r[a]+=1
i=r.index(3);d=A.index;L=n-d(i,d(i)+1);*X,=range(1,n+1)
for i in X:f[i]=e=f[i-1]*i%M;r[i]=pow(e,M-2,M)
for k in X:print((f[n]*r[k]*r[n-k]-(k<=L)*(f[L-1]*r[k-1]*r[L-k]))%M)

Submission status: Wrong Answer

Solution code:
n = int(input())
seq = input().split()
lc = 'a'
already = []
for idx,c in enumerate(seq):
    if c in already:
        break
    already.append(c)
    lc = c

left = seq.index(c)
right = list(reversed(seq)).index(c)
middle = n-left-right-2
# print(left,middle,right,lc)
# print(seq)
NUM = 10**9+7

# def f(n):
#     if n<=1:
#         return 1
#     else:
#         return n*f(n-1)
#
from math import factorial
def f(n,k):
    if n<k:
        return 1
    else:
        return n*f(n-1,k)


def c(n,k):
    if k == 1:
        return n
    if k == n:
        return 1
    # return f(n)//(f(k) * f(n-k))
    return f(n,max(k,n-k))//f(min(k,n-k),1)

# from itertools import combinations as combi
# def c(n,k):
#     return len(list(combi(range(n),k)))

def calc(n,k):
    if k == 1:
        return n-1
    if k == n:
        return 1
    # if k == n-1:
    #     return c(n,k) - 1
    # if k == 2:
    #     return c(n,k) - lidx - (n-ridx)
    # if k == 3:
    #     return c(n,k) - c(lidx,1) * c(n-ridx,1)
    # if k == 4:
    #     return c(n,k) - c(lidx,1) * c(n-ridx,2) - c(lidx,2) * c(n-ridx,1)
    if k-1 > left+right:
        return c(n,k)
    else:
        return c(n,k) - c(left+right, k-1)


for k in range(1,n+1 +1):
    print(int(calc(n+1,k))%NUM)

Submission status: Wrong Answer

Solution code:
from math import factorial
def nCk(n,k,mod=10**9+7):
    if n<k or k<0 or n<0:return 0
    return fact[n]*inv[n-k]*inv[k] % mod

mod = 10**9+7
n=int(raw_input())
a=map(int,raw_input().split())
cnt=[0]*(n+1)
for i in xrange(n+1):
    cnt[a[i]]+=1
dnum=0
for i in xrange(n+1):
    if cnt[i]==2:
        dnum=i
        break
idx=[]
fact=[0]*(n+5)
fact[0]=1
inv=[0]*(n+5)
inv[n+1]=pow(factorial(n+1), mod - 2, mod)
for i in xrange(n+1):
    fact[i+1] = (i+1)*fact[i]%mod
for i in xrange(n, -1, -1):
    inv[i] = inv[i+1]*(i+1) %mod
for i in xrange(n+1):
    if dnum==a[i]:
        idx.append(i)

y=n-idx[1]
x=idx[0]

for i in xrange(n+1):
    #print nCk(y,i)
    print (nCk(n+1, i+1) - nCk(y,i)-x*nCk(y,i-1)%mod)%mod

Submission status: Wrong Answer

Solution code:
def nCk(n,k,mod=10**9+7):
    if n<k or k<0 or n<0:return 0
    return fact[n]*inv[n-k]*inv[k] % mod

mod = 10**9+7
n=int(raw_input())
a=map(int,raw_input().split())
cnt=[0]*(n+1)
for i in xrange(n+1):
    cnt[a[i]]+=1
dnum=0
for i in xrange(n+1):
    if cnt[i]==2:
        dnum=i
        break
idx=[]
fact=[0]*(n+5)
fact[0]=1
inv=[0]*(n+5)
inv[0]=pow(1,mod-2,mod)
for i in xrange(n+1):
    fact[i+1] = (i+1)*fact[i]%mod
    inv[i+1] = pow(fact[i+1], mod-2,mod)
for i in xrange(n+1):
    if dnum==a[i]:
        idx.append(i)

y=n-idx[1]
x=idx[0]

for i in xrange(n+1):
    #print nCk(y,i)
    print (nCk(n+1, i+1) - nCk(y,i)-x*nCk(y,i-1)%mod)%mod

Submission status: Wrong Answer

Solution code:
N=int(raw_input())
L=map(int,raw_input().split())
d={}
mod=1000000007
def nCk(n,k):
    a=b=1
    if k==0 or n<k:
        return 0
    k=min([k,n-k])
    for i in range(k):
        a=a*(n-i)
        b=b*(1+i)
    return a/b

for i in range(N):
    if d.get(L[i],0):
        break
    d[L[i]]=i+1

print N-1
for j in range(2,N+1):
    print (nCk(N,j)-nCk(N-i,j))%mod

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

for i in range(1,n+2):

    ans=scm.comb(n+1, i, 1) - scm.comb(n+1-2, i-1 ,1) 

    print(ans % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def comb(n, k):
    if k<0 or n<k:
        return 0

    if n-k<k:
        k=n-k
    return round(math.factorial(n)/math.factorial(k)/math.factorial(n-k))

n=int(input())
a=np.array([int(i) for i in input().split()])

count_lst=[[] for _ in range(n)]
for i in range(n+1):
    count_lst[a[i]-1].append(i)

for i in range(n):
    if len(count_lst[i])==2:
        left=count_lst[i][0]
        right=count_lst[i][1]
gapLen=right-left-1

del count_lst


base=10**9+7

for k in range(1, n+2):
    #print("k={}".format(k))
    retVal=0
    #retVal+=comb(n-1, k-2)#両方in
    #print(retVal)
    #retVal+=comb(n-1, k)#両方out
    #print(retVal)
    
    #retVal+=comb(n-1-gapLen, k-1)#片方in, gapから1つも選ばれない
    #print(retVal)    
    #retVal+=2*(comb(n-1, k-1)-comb(n-1-gapLen, k-1))
    print(retVal%base)

Submission status: Wrong Answer

Solution code:
def nCk(n,k,mod=10**9+7):
    if n<k or k<0 or n<0:return 0
    return fact[n]%mod * pow(fact[n-k]*fact[k],mod-2,mod) % mod

mod = 10**9+7
n=int(raw_input())
a=map(int,raw_input().split())
cnt=[0]*(n+1)
for i in xrange(n+1):
    cnt[a[i]]+=1
dnum=0
for i in xrange(n+1):
    if cnt[i]==2:
        dnum=i
        break
idx=[]
fact=[0]*(n+5)
fact[0]=1
for i in xrange(n+1):
    fact[i+1] = (i+1)*fact[i]%mod
for i in xrange(n+1):
    if dnum==a[i]:
        idx.append(i)

y=n-idx[1]
x=idx[0]

for i in xrange(n+1):
    #print nCk(y,i)
    print (nCk(n+1, i+1) - nCk(y,i)-x*nCk(y,i-1)%mod)%mod

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def comb(n, k):
    if n<k:
        return 0
    if k<0:
        return 0

    if n-k<k:
        k=n-k
    return round(math.factorial(n)/math.factorial(k)/math.factorial(n-k))

n=int(input())
a=np.array([int(i) for i in input().split()])

count_lst=[[] for _ in range(n)]
for i in range(n+1):
    count_lst[a[i]-1].append(i)

for i in range(n):
    if len(count_lst[i])==2:
        left=count_lst[i][0]
        right=count_lst[i][1]
gapLen=right-left-1

for k in range(1, n+2):
    print(gapLen)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
a = map(int, raw_input().split())
BI = 10**9+7

cache = {}
def factorial(n):
  if n in cache:
    return cache[n]

  if n == 0:
    cache[n] = 1
    return 1

  x = 1
  m = n
  while m > 0:
    x *= m
    m -= 1
  cache[n] = x
  return x

def nck(n,k):
  return factorial(n) / factorial(k) / factorial(n-k)

x = -1
j = -1
s = set()
for i in range(n+1):
  if a[i] in s:
    x = a[i]
    j = i
    break
  else:
    s.add(a[i])

b = a[:i] + a[i+1:]

N = n + 1

print n
for i in range(2,N+1):
  if i > N-j:
    print nck(N,i) % BI
  else:
    print (nck(N,i) - nck(N-j,i)) % BI

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
a=list(map(int,input().split()))
c=[]
for i in range(N+1):
  if a[i] in c:
    b=a[i]
    j=c.index(a[i])
    k=i
    L=j+N-k
    break
  c+=[a[i]]
Base=N+1
Minu=1
for i in range(0,min(L+1,N+1)):
  print((Base-Minu)%(10**9+7))
  Base=int(Base*(N-i)/(i+2))%(10**9+7)
  Minu=int(Minu*(L-i)/(i+1))%(10**9+7)
  #print(int(math.factorial(N+1)/(math.factorial(i+1)*math.factorial(N-i))-math.factorial(L)/(math.factorial(i)*math.factorial(L-i))))
for i in range(L+1,N+1):
  print(Base%(10**9+7))
  Base=int(Base*(N-i)/(i+2))%(10**9+7)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
a=list(map(int,input().split()))
c=[]
for i in range(N+1):
  if a[i] in c:
    b=a[i]
    j=c.index(a[i])
    k=i
    L=j+N-k
    break
  c+=[a[i]]
print(N)
for i in range(1,min(L+1,N+1)):
  print(int(math.factorial(N+1)/(math.factorial(i+1)*math.factorial(N-i))-math.factorial(L)/(math.factorial(i)*math.factorial(L-i))))
for i in range(L+1,N+1):
  print(int(math.factorial(N+1)/(math.factorial(i+1)*math.factorial(N-i))))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
xs = [int(c) for c in input().split()]

mod = (10 ** 9) + 7

c = Counter(xs)

for k, v in c.items():
    if v == 2:
        dup = k

dup_idx = [i for i, v in enumerate(xs) if v == dup]

facts = [1]
for i in range(1, n + 3):
    facts.append(facts[-1] * i % mod)

def inv(x):
    return pow(x, mod - 2, mod)

def comb(p, q):
    if (not 0 <= q <= p) or p < 0:
        return 0
    return facts[p] * inv(facts[q]) % mod * inv(facts[p - q]) % mod

tl = n + 1
for l in range(1, n + 2):
    use_no = comb(tl - 2, l)
    use_both = comb(tl - 2, l - 2)
    use_one = comb(tl - 2, l - 1) * 2 - comb(min(dup_idx) + (tl - 1 - max(dup_idx)), l - 1)
    print(use_no + use_both + use_one)
    # print(use_no,use_both ,use_one)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)

ind = 0
for i, x in enumerate(A):
    if C[x] > 1:
        ind = i - ind

mod = 10 ** 9 + 7


def nCr(a, b):
    p = q = 1
    for i in range(a - b + 1, a + 1):
        p *= i
        p %= mod
    for i in range(2, b + 1):
        q *= i
        q %= mod
    return p * pow(q, mod - 2, mod) % mod


for i in range(1, n + 2):
    res = nCr(n + 1, i) - nCr(n - ind, i - 1)
    res %= mod
    print(res)

Submission status: Time Limit Exceeded

Solution code:
MOD = 10**9 + 7
def nCr(n,r):
    numerator, denominator = 1, 1
    for i in range(r):
        # n * N-1 * ... * n-r+1
        numerator = numerator * (n-i) % MOD
        # r * r-1 * ... * 1
        denominator = denominator * (r-i) % MOD

    # フェルマーの小定理より、aの逆元（逆数）が、a**(m-2)とのこと
    denominator = pow(denominator, MOD-2, MOD)
    return numerator * denominator % MOD


N = int(input())
A = list(map(int, input().split()))

idxs = [[] for _ in range(N)]
for i,a in enumerate(A):
    idxs[a-1].append(i)

for i in range(N):
    if len(idxs[i]) == 2:
        first = idxs[i][0]
        second = idxs[i][1]
        break

for i in range(1, N+2):
    if i == 1:
        print(N)
    elif i == N+1:
        print(1)

    else:
        a = nCr(N+1, i)
        # firstより左にある数字とsecondより右にある数字からi-1個、firstかsecondを選んで長さiの部分列が作れる場合
        cnt = first + (N-second)
        if cnt >= i-1:
            a -= nCr(cnt, i-1)
            a %= MOD
        
        print(a)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())

A = list(map(int, input().split()))
c = Counter(A)
s = c.most_common()[0][0]
idx_s = [i for i,x in enumerate(A) if x == s]
l = idx_s[0]
r = idx_s[1]

def nCr(n,r):
  if n < 0 or r < 0 or n < r: return 0
  if n - r < r: r = n - r
  if r == 0: return 1
  if r == 1: return n
  
  # 分子のn*(n-1)*...がr個分続くやつ
  numerator = [n-r+k+1 for k in range(r)]
  # 分母：r!=r*(r-1)*...*3*2の要素
  denominator = [k+1 for k in range(r)]
  
  # 分母の要素で割れる部分を割っていく部分
  for p in range(2, r+1):
    # 分母は1,2,3,...rのようになっており、1は意味がないのでスキップした形か
    pivot = denominator[p-1]
    if pivot > 1:
      # 分子のX番目と分母のX-offset番目が共通の約数を持つということだと思う。piv分ずれているのだから、pivの倍数というところか
      offset = (n-r) % p
      for k in range(p-1, r, p):
        # 約分できる要素について割る
        numerator[k - offset]  /= pivot
        denominator[k] /= pivot
        
  ret = 1
  for k in range(r):
    if numerator[k] > 1: ret *= int(numerator[k])
      
  return ret

for i in range(1,N+2):
    print((nCr(N+1, i) - nCr(l+N+1-(r+1), i-1)) % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
mod=10**9+7


def mod_combination(n, r, mod=10**9+7):
    if r > n:
        return 0
    fact = 1
    for i in range(n-r+1, n+1):
        fact = fact * i
    divisor = 1
    for j in range(1, r+1):
        divisor = divisor * j
    return fact // divisor % mod

n = int(input())
seq = list(map(int, input().split()))
num_set = set()
ind_dict = {}
for i in range(n+1):
    if seq[i] in num_set:
        left = ind_dict[seq[i]]
        right  = i
        break
    num_set.add(seq[i])
    ind_dict[seq[i]] = i



for k in range(1, n+2):
    print(mod_combination(n+1, k) - mod_combination(n - right + left, k-1))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-


import sys


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret


# python template for atcoder1
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
N = n+1
A = list(map(int, input().split()))
MOD = 10**9+7
already = set()
for i, l in enumerate(A):
    if l in already:
        dup_ind = i
        dup_num = l
        break
    else:
        already.add(l)
before_first_dup_num = A.index(dup_num)
after_dup_num = N-dup_ind-1

F = FactMod(n+1, MOD)
for k in range(1, n+2):
    all_pattern = F.comb(N, k)
    rem_pattern = 0
    for first_rem in range(k):
        before_first_rem = F.comb(
            before_first_dup_num, first_rem) if before_first_dup_num >= first_rem else 0
        after_dup_rem = F.comb(
            after_dup_num, k-1-first_rem) if after_dup_num >= k-1-first_rem else 0
        rem_pattern += before_first_rem*after_dup_rem
    print((all_pattern-rem_pattern+MOD) % MOD)

Submission status: Time Limit Exceeded

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
mod=10**9+7
from collections import Counter
def comb(n,r):
    if n<r:
        return 0
    else:
        r=min(r,n-r)
        result=1
        for i in range(n-r+1,n+1):
            result*=i
        for i in range(1,r+1):
            result//=i
        return result
n=int(input())
A=list(map(int,input().split()))
C=Counter(A)
i=C.most_common()[0][0]
idx=[k for k, x in enumerate(A) if x==i]
for k in range(1,n+2):
    print((comb(n+1,k)%mod-comb(n+idx[0]-idx[1],k-1)%mod)%mod)

Submission status: Time Limit Exceeded

Solution code:
#<` _!~`    (?<?OrvvvzzzI`       .(. C/~.~..~..~.(~.~.~_~..~.~~.~~~<-4X~..<;!.``.-XyyyyyyyyyyyyyXwwXy
#~~```````   ...+trrrrrrI`   `    `_(!`  ` _ .._-:..~-.~_....  `  ``__C..;<_.~`..uuZZZZZZZZZZZZX00VT0
#  ` ...-((<zltttttlttttl      `  ~(_ .(>_<~~(c~+~~~_:~(~~~(~~.~..-.  -.<<!.`..JvzzzzzzzzXZC17?C1- `
#---((++zllllllllllllllll. `     `<<<~(z<J<~(v>(C~.~(l~(<~~(o~~~~~(_~~(+...(+zOttrrttv<!<1>` .._----(
#=======================?_  `   ` <(~~jO(Z_(c((y(~~~(I~(_<~(wx~~(~~l~~~( ``.<(v<<111<-(-....(++zOwwww
#???>>?>>>>?>>>>>>>>>>>>>:`   `  `(>~(wZz$~/  (`.__~(r+~!_<~OXZ>(_~z_~(~C-.`.(z??????=1zzOrwwwVwzvrrZ
#wOwzzz++<;;;;;;;++++++<:: `      .<~(zXkr(`  -` ><~(ww-~  ~(?zx(<~z>~(l<_<_`.-+??1zwwZuVzzvOrtrwvwXk
#WkuzrZXyVfWX&swXZXWZyWWkI`  ` ` ` _~(uuZG&..(o-..(:~zz-_...~<(Oo<(wI~~z(.`._``(wzuXUwrrwXXWWVrrrXWXW
#HkkkwwOOwXuuXWHWyXXXZZZyV`   `   `<((uuI(`2-MM/``_<<(r;.jTYWHRwk>(zI-~wG,````. OwzvwwXXkdWHrwXkWHkkW
#HkWWWXwwWXwVwXwXXXXXUXU3_`    ` `((2Xk% .HdMX\   .._(l``dndMN .(wuI<~XWI<-...`(XW0UwwWpWqqbkHHWHpHg
#WWbpfWWXUWXwwwwwwXWkXXZ0~:` `  `  .xWwWO``?kwf     `  ?!`zXMWY`(duXG$(uuu:~~~_<&jWZOXWWHWWXWWWWWHmgg
#gHHHkHUXwuzXXuXXXXXUWHk$~(  `    ``dWXWz{`````` ``      ` ?"= .CuXDd$duuuI~~~~_wXkkWSOzdHWHHHHHHHHHW
#UUuUXXkXXXXXXuXSXXZXpWW<~(.`  `  ` -v4ur```````  `  ` `` `````.ZXXVjwuuuuz<~~~~XWgHHkwwWgkluXWgHzzUW
#ZXXydWkwuwwOwVVOlwuXSIv~~_;`   `   ,C~(w-````  `     ` ``````  (XZ~?fuuuuul~~~~dHHMk0wdq@HOW@MHMHZwH
#kwXmwOOOtzwZwOzvwWkWNk>~~(w-` `  ./!.>~jn `   `   `      ` ```(JkZ~(pXuuuuI~~~~(WHSwwWWHMNKHMHM@HWWk
#HHH@HkuOlzyzzwZVXUMMM#~~~zXl~__~_<!.~(<_Ol` `  ` `   `  `   `(uXuI~+mKuuuuz<~~~(zzwkp0WHHHWkHMWHMWW&
#WWqHMHHWUU0wOzlzdHMHHD~~(zI(_~__~~._`__-(wS-.`  `  `  ` `  .vWHHuC(zgHuuuuul~~~~V7UHkAwzwWMMHWmdWHWH
#dH@HMHWWXwOzzzdqHMMMM<~~ju2(>-~_ __`. .`<?Xytw<.. ` ` ..+llzOwUHu>((HUkuuXXI~~~~jaXHWWHwXMNmmddVNmHH
#XHMHHHWkOwVVVUMMHHHM@~~(wuZ+-_.-~`.~``.`<~jXZt<~.~~<~~~(ttttltOSZ~zj1zUuuuWz<~~~?MHXWWMMHHWHMMNHMMMN
#WHWH@HHkXXtXkXMHHMHMt~~(uur-_<<``.!` `` (+(w>_~_~~.~.._(vzvzOzdzC(RkkAdXuuWul~~~_HH@@MMM961dwf<zKMNW
#MMHWMHMHkQWH@MMMH@MK~~_yuz!` _<<! ` ` ``_1_(l``.~__`  `..! ?OXSZ_dSUUUUSuuXkI~~~~JqHHkkk+vOC+JmkMMHX
#HMg@MMMMHHHbRvdHMMMt~~(uuZ`  .~._`  ````<(<(0 ` `. ````` .```,w>?OKrrOOdXuuWw_~~~(wv<?zXHmdMMM#79WWW
#m@@HHHHH@HHHHwWWWHH<~~(uuw ` ... ` ` ` `! I(1_``  _~__~   ``.XZ~`. (zrtrWuuXu>~~~~jk0dHNHMMMH91HH1VX
#HWrXWWWHHHWXHMMMHX<~~(uXuudh.` ._ `     `.v``` ` `< (``` ``!_ ` `   `.wwwdXuWw~~~~~wHMMMMNmsdN#WSigg
#WK0OVOwWMMHHMMHkWD~~~juSuXHMK+  (_``  ` ``` ` ` ` ~ <`  `  `` ` ```~ `OzZzXuXk:~~~~(V9WNMMNM##Z+v<XM
#MI+vzzzZTWHHMMMHH<~~_wXuZWHkkWm,.< `.  `  `  ` ` `_.~ ` `` ` ` ` ` ` `jzXuzWZWI~~~~~wMMMMM5ZnsJGJWNQ
#XOOwwOzOdkwTWUWWr~~~(uXuXMMMMHHMm(_`_ `  `  ` ``   (` `  ` ` `  `_.```(wvXuzWXk_~~~~dMMHHMM&N9Q8WHMW
#UVwOIjk0+zwU?4kX<~~~(uWZHHMMHHHMMNc-_` `` ` `   ``._`` `  ` ` ```__ `  .OZXXXWR:~~~~(uWMHHM#mV3&QQMQ
import sys
input = sys.stdin.readline

n = int(input())
A = tuple(map(int,input().split()))
p = 10**9+7
used = [-1]*n
for i in range(n+1):
    if used[A[i]-1]>=0:
        a = used[A[i]-1]
        b = i
        break
    used[A[i]-1] = i


#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

######################################################


#pは素数とする

#fact[i] : i! modp (0<= i <p) O(p)
fact = [1]
k = 1
for i in range(1,n+2):
    k = k*i%p
    fact.append(k)


#n! = a p^eとしたときのeを求める (O(logp n)
def mod_e(n,p):
    res = 0
    while n >= p:
        res += n//p
        n = n//p
    return res

#n! = a p^eとしたときのa mod pを求める  (O(logp n)
def mod_fact(n,p):
    if n==0:
        return 1
    
    
    res = mod_fact(n//p,p)
    
    if n//p %2 != 0:
        return res*(p-fact[n%p])%p
    return res*fact[n%p]%p
    
######################################################

#nCk mod p
def mod_comb(n,k,p):
    if n < 0 or k < 0 or n<k:
        return 0
    e1 = mod_e(n,p)
    e2 = mod_e(k,p)
    e3 = mod_e(n-k,p)
    #pで割り切れる場合
    if e1 > e2 + e3:
        return 0

    #pで割り切れない場合
    a1 = mod_fact(n,p)
    a2 = mod_fact(k,p)
    a3 = mod_fact(n-k,p)
    return a1 * mod_inv(a2*a3%p,p) %p
#print(a,b)
for i in range(1,n+2):
    res = mod_comb(n+1,i,p)-mod_comb(a+n-b,i-1,p)
    if res < 0:
        res += p
    print(res)