from functools import reduce
from collections import Counter

N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

LR = reduce(lambda a,b:a+[a[-1]+b],A,[0])
LR = list(map(lambda x:x%M,LR))

Lc = Counter(LR[:-1])
Rc = Counter(LR[1:])
LRCount = Counter(LR)
LRNum = [int(LRCount[k]*(LRCount[k]-1)/2) for k in LRCount]

LRNum = sum(LRNum)
print(LRNum)