N,M = map(int,input().split())
Alist = list(map(int, input().strip().split()))
r = list(range(len(Alist)))
r[0] = Alist[0]
for i in range(1,len(Alist)-1):
    r[i] = r[i-1] + Alist[i]
for i in range(len(r)):
    r[i] = r[i]%M
p = [0] * M
for i in range(len(r)):
    p[r[i]] = p[r[i]] + 1
def kaijou(n):
    if n == 0:
        return 1
    else:
        v = n
        for i in range(1,n):
            v = v*i
        return v      
def combi(n):
    if n == 0:
        return 0
    if n == 1:
        return 0
    else:
        return kaijou(n)/((kaijou(n-2))*2)
s = 0
for i in range(len(p)):
    s = s + combi(p[i])
    print(s)
s = s + p[0]
print(int(s))