from collections import defaultdict


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

b = 0
c = defaultdict(int)
c[0] = 1
cnt = 0
for a in a:
    b = (b + a) % m
    cnt += c[b]
    c[b] = c[b] + 1
print(cnt)