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

sumList = [0] * n
sumList[0] = a[0] % m
number = {}

for i in range(1, n):
    sumList[i] = (sumList[i - 1] + a[i]) % m
    number[sumList[i]] = 0

for i in range(n):
    number[sumList[i]] += 1

ans = 0

for key, value in number.items():
    ans += value * (value - 1) // 2
    if key == 0:
        ans += value

print(ans)
