import numpy as np

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

ans = 0

amari = np.zeros(m, dtype='int32')
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
ans += amari[0]

print(ans)