n, m = map(int, input().split())
lst = list(map(int, input().split()))
imod = []
for i in range(n):
    imod = imod + [sum(lst[0:i]) % m]
imod = imod + [sum(lst) % m]
s = 0
for i in range(n):
    for j in range(i+1,n+1):
        if imod[i] == imod[j]:
            s = s + 1
print(s)