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

s = [0]
for i in range(n):
    s.append(sum(l[:i+1]))

s = [j%m for j in s]
s.sort()

ans = 0
while s:
    cnt = s.count(s[0])
    s = s[cnt:]
    ans += cnt*(cnt-1)//2

print(ans)