from collections import Counter
import math

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

cum_list = [sum(a_list[:i+1]) % m for i in range(n)]

count = Counter(cum_list)
ans = 0
for k in list(count.values()):
    if k > 1:
        ans += math.factorial(k) / (math.factorial(k - 2) * 2)

ans += count[0]
print(int(ans))
