Buggy python submission (verdict: Time Limit Exceeded):
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)


Fixed submission:
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]

MOD = 10**9+7
fac = [1,1] + [0]*N
finv = [1,1] + [0]*N
inv = [0,1] + [0]*N
for i in range(2,N+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
 
def nCr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

for i in range(1,N+2):
    print((nCr(N+1, i) - nCr(l+N+1-(r+1), i-1)) % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
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))

Fixed submission:
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]

MOD = 10**9+7
fac = [1,1] + [0]*N
finv = [1,1] + [0]*N
inv = [0,1] + [0]*N
for i in range(2,N+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
 
def nCr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

for i in range(1,N+2):
    print((nCr(N+1, i) - nCr(l+N+1-(r+1), i-1)) % MOD)