from collections import defaultdict
N, M = map(int, input().split())
Ai = list(map(int, input().split()))

for i in range(N):
    for j in range(i, N):
        t = 0
        for k in range(i, j + 1):
            t += Ai[k]

#-----------------
fact = [0 for _ in range(N + 1)]
fact[0] = 1
for i in range(1, N + 1):
    fact[i] = fact[i - 1] * i

def comb(n, m):
    return fact[n] // (fact[m] * fact[n - m])

#---------------
d = defaultdict(int)
total = Ai[0] % M
d[0] = 1
d[total] += 1
for i in range(1, N):
    total = (total + Ai[i]) % M
    d[total] += 1
#-----------------
ans = 0
for k in d.keys():
    c = d[k]
    if c >= 1:
        ans += comb(c, 2)
print(ans)