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

array1 = [0]
array2 = [1]
num = 0
for i in A:
    num += i
    x = num % M
    if x in array1:
        array2[array1.index(x)] += 1

    else:
        array1.append(x)
        array2.append(1)

ans = 0
for i in array2:
    if i > 1:
        ans += (i * (i-1)) // 2

print(ans)
