from scipy.misc import comb
import numpy as np
from collections import defaultdict
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = np.cumsum(A)
A %= M
d = defaultdict(lambda:0)
d[0] = 1
for i in range(N):
    d[A[i]] += 1
ans = 0
for k in d:
    ans += comb(d[k],2)
print(int(ans))