import itertools
import collections
from scipy.special import comb

n,m = map(int,input().split())
a = list(map(int,input().split()))
ac = [0]
ac += list(itertools.accumulate(a))

re = [i % m for i in ac]
c = collections.Counter(re)

ans = 0
for v in c.values():
    if v >= 2:
        ans += comb(v,2,exact=True)
print(ans)