from collections import Counter
N, M = map(int,input().split())
A = list(map(int,input().split()))
L = [0]*(N+1)
for i in range(1,N+1):
    L[i] = (L[i-1] + A[i-1]) % M
L = Counter(L).values()
ans = 0
for i in L:
    ans += i * (i-1) // 2
print(ans)
