from collections import Counter
n, m = map(int, input().split())
a = list(map(int, input().split()))

cumsum = [0]
for i in a:
    cumsum.append((cumsum[-1] + i) % m)

ans = 0
for v in Counter(cumsum).values():
    ans += v * (v-1) // 2

print(ans)