N,M = map(int,input().split())
A = list(map(int,input().split()))
from collections import defaultdict
r = defaultdict(lambda:0)

s = 0
for i in range(N):
    s += A[i]
    s %= M
    r[s] += 1

ans = r[0]
for s in r:
    ans += (r[s]*(r[s]-1))//2

print(ans)