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
mae = s[0]
cnt = 1
for k in range(1, n+1):
    if s[k]==mae:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        mae = s[k]
        cnt = 1
    if k==n:
        ans += cnt*(cnt-1)//2

print(ans)