N , M = map(int, input().split())
an = list(map(int,input().split()))
ca = [0] * N
ca[0] = an[0] % M
ans = 0
for i in range(1,N):
    ca[i] = (ca[i-1] + an[i]) % M
for i in range(N):
    if ca[i] % M == 0:
        ans += 1
    for j in range(i):
        if (ca[i] - ca[j]) % M == 0:
            ans += 1
print(ans)