
def cal_comb(n,r):
    ret = 1
    for i in range(1,n+1):
        ret *= i
    for i in range(1,n-r+1):
        ret *= i
    for i in range(1,r+1):
        ret //= i
    return ret


N,M = map(int,input().split())
L = list(map(int,input().split()))

from itertools import accumulate
accumulated =  [0]+list(accumulate(L))
accumulated = map(lambda x:x%M,accumulated)
def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())
c = counter(accumulated)
ans = 0
for x in c:
    ans += cal_comb(x[1],2)

print(ans)

