import numpy as np
n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
b = np.insert(((a%m).cumsum()%m),0,0)
c = set(b)
ans = 0
for i in c:
    t = (b==i).sum()
    if t>=2:
        ans+=t*(t-1)/2
print(int(ans))