import math
#n,m = 3,2
#a = [4,1,5]
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
for i,ai in enumerate(a):
    if i == 0:
        b[i] = ai % m
    else:
        b[i] = (ai + b[i-1]) % m

ans = 0

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(m):
    c = b.count(i)    
    if c >= 2:
        ans += combinations_count(c%m,2)
ans += b.count(0)

print(ans)
