import numpy as np

n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

amari = np.zeros(m, dtype = 'int64')
s = 0

for i in range(n):
    s += a[i]
    s %= m
    amari[s] += 1

    
for i in range(m):
    #ans += amari[i]*(amari[i]-1)//2
    if amari[i]%2 == 0:
        ans += amari[i]//2 * (amari[i]-1)
    else:
        ans += (amari[i]-1)//2 * amari[i]
    if i==0:
        ans += amari[i]
print(ans)