from collections import defaultdict

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

data = defaultdict(int)
now = 0
data[0] = 1
for i in a:
    now = (now+i)%m
    data[now] += 1

ans = 0
for x in data.values():
    ans += x*(x-1)//2

print(ans)