N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

sums = [0]*N
remainders = [0]*M

ans = 0

for i in range(N):
    if i == 0:
        t = A[i] % M
    else:
        t = (A[i] % M + sums[i-1]) % M
    sums[i] = t
    remainders[t] += 1
    ans += remainders[t] if t == 0 else remainders[t] - 1

print(ans)
