N, M = map(int, input().split())
A = [int(i) for i in input().split()]

modDict = {}
B = 0
for i in range(N):
    B += A[i]
    if B%M in modDict:
        modDict[B%M] = modDict[B%M] + [i]
    else:
        modDict[B%M] = [i]

count = 0
for i in modDict:
    count += (len(modDict[i]) * (len(modDict[i]) -1))//2
    if i == 0:
        count += len(modDict[i])
print(count)