#coding:utf-8

def inpl(): return list(map(int, input().split()))

n,m = inpl()
A = inpl()

B = []
tmp = 0
for a in A:
    tmp += a
    B.append(tmp)

ans = 0

for i in range(n):
    if B[i] % m == 0: ans += 1

for i in range(1,n):
    for j in range(0,i):
        if (B[i] - B[j]) % m == 0: ans += 1

print(ans)