N,M=map(int,input().split())
A=[int(i) for i in input().split()]
S=[0 for i in range(N+1)]
for i in range(N):
    S[i+1]=(S[i]+A[i])%M
D=dict()
for i in range(N+1):
    if S[i] in D:
        D[S[i]]+=1
    else:
        D[S[i]]=1
print(D)
for si in D:
    print(D[si])
print(S)