from collections import Counter
n,m = map(int,input().split())
A = list(map(int,input().split()))
B = [0]
for a in A:
    B.append((B[-1]+a)%m)
D = Counter(B)
res = 0
for v in D.values():
    res += v*(v-1)//2
print(res)
