import collections 
cnt = collections.Counter({0:1})
n,m = map(int,input().split())
a = [0] + [int(x) for x in input().split()]
ans = 0
for i in range(1,n+1):
    a[i] += a[i-1]
    a[i] %= m
    ans += cnt[a[i]]
    cnt[a[i]]+=1
print(ans)