Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(item) for item in input().split()]

nCk = [0] * (n+2)
nCk[1] = n + 1
for i in range(2,n+2):
    nCk[i] = (nCk[i-1] * (n+1-i+1) // i)

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

nb = n-r+l
nb1Ck = [0] * (n + 2)
nb1Ck[0] = 1
nb1Ck[1] = nb 
for i in range(2, nb+2):
    nb1Ck[i] = (nb1Ck[i-1] * ((nb+1)-i) // i)

for i in range(1, n+2):
    print((nCk[i] - nb1Ck[i-1])%(10**9 + 7))

Fixed submission:
n = int(input()) + 1
a = [int(item) for item in input().split()]
MOD = 10**9 + 7

def mod_pow(x, n):
    ans = 1
    while(n != 0):
        if n & 1:
            ans = ans * x % MOD
        x = x * x % MOD
        n = n >> 1
    return ans

fac = [1] + [0] * n
inv_fac = [1] + [0] * n
for i in range(1, n+1):
    fac[i] = fac[i-1] * (i) % MOD
    inv_fac[i] = inv_fac[i-1] * mod_pow(i, MOD-2) % MOD

def mod_nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if n < r or n < 0:
        return 0
    tmp = inv_fac[n-r] * inv_fac[r] % MOD
    return tmp * fac[n] % MOD 

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

for i in range(1, n+1):
    total = mod_nCr(n, i)
    doubled = mod_nCr(n -(r-l) - 1, i-1)
    ans = total - doubled
    if ans < 0:
        ans += MOD
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(item) for item in input().split()]

nCk = [0] * (n+2)
for i in range(1,n+2):
    if i == 1:
        nCk[1] = n+1
    else:
        nCk[i] = (nCk[i-1] * (n+1-i+1) // i) # % (10**9 + 7)

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

nb1Ck = [0] * (n + 2)
nb1Ck[0] = 1
for i in range(1,(n-r+l)+2):
    if i == 1:
        nb1Ck[1] = n-r+l
    else:
        nb1Ck[i] = (nb1Ck[i-1] * ((n-r+l+1)-i) // i) # % (10**9 + 7)

for i in range(1, n+2):
    print((nCk[i] - nb1Ck[i-1])%(10**9 + 7))

Fixed submission:
n = int(input()) + 1
a = [int(item) for item in input().split()]
MOD = 10**9 + 7

def mod_pow(x, n):
    ans = 1
    while(n != 0):
        if n & 1:
            ans = ans * x % MOD
        x = x * x % MOD
        n = n >> 1
    return ans

fac = [1] + [0] * n
inv_fac = [1] + [0] * n
for i in range(1, n+1):
    fac[i] = fac[i-1] * (i) % MOD
    inv_fac[i] = inv_fac[i-1] * mod_pow(i, MOD-2) % MOD

def mod_nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if n < r or n < 0:
        return 0
    tmp = inv_fac[n-r] * inv_fac[r] % MOD
    return tmp * fac[n] % MOD 

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

for i in range(1, n+1):
    total = mod_nCr(n, i)
    doubled = mod_nCr(n -(r-l) - 1, i-1)
    ans = total - doubled
    if ans < 0:
        ans += MOD
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
n = int(input())
a = [int(item) for item in input().split()]

def combination(n, r):
    if n-r < 0:
        return 0
    return factorial(n) // (factorial(n-r) * factorial(r))

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

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

Fixed submission:
n = int(input()) + 1
a = [int(item) for item in input().split()]
MOD = 10**9 + 7

def mod_pow(x, n):
    ans = 1
    while(n != 0):
        if n & 1:
            ans = ans * x % MOD
        x = x * x % MOD
        n = n >> 1
    return ans

fac = [1] + [0] * n
inv_fac = [1] + [0] * n
for i in range(1, n+1):
    fac[i] = fac[i-1] * (i) % MOD
    inv_fac[i] = inv_fac[i-1] * mod_pow(i, MOD-2) % MOD

def mod_nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if n < r or n < 0:
        return 0
    tmp = inv_fac[n-r] * inv_fac[r] % MOD
    return tmp * fac[n] % MOD 

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

for i in range(1, n+1):
    total = mod_nCr(n, i)
    doubled = mod_nCr(n -(r-l) - 1, i-1)
    ans = total - doubled
    if ans < 0:
        ans += MOD
    print(ans)