f = lambda: list(map(int,input().split()))
def s(l,m):
    ans = 0
    for i in range(len(l)):
        ans += l[i]
        ans %= m
    return ans

n,m = f()
a = f()
a = [s(a[:i],m) for i in range(n+1)]
ans = 0
from collections import Counter
for v in Counter(a).values():
    ans += v*(v-1)//2
print(ans)