n,m = map(int,input().split())
lis = list(map(int,input().split()))
rui = [0]
for l in lis:
    rui.append((rui[-1]+l)%m)

count = 0
for i,r in enumerate(rui):
    if i == len(lis):
        break
    for j in range(i+1,len(rui)):
        #print(rui[j],rui[i])
        if rui[j]==rui[i]:
            count += 1
#print(rui)
print(count)