n, m = map(int, input().split( ))
a = list(map(int, input().split( )))
mod = {0:1}###
a_sum = 0
for i in range(n):
    a_sum += a[i]
    a_sum %= m
    if a_sum in mod.keys():

        mod[a_sum] += 1
    else:

        mod[a_sum] = 1

ans = 0
for key in mod.keys():
    k = mod[key]

    ans += k*(k-1)//2

print(ans)