N, M = map(int, input().split())
A = list(map(int, input().split()))

array = [0]
num = 0
for i in A:
    num += i
    array.append(num % M)

array.sort()
ans = 0
while array:
    counter = array.count(array[0])
    array = array[counter:]
    ans += (counter * (counter - 1)) // 2

print(ans)
