import sys 
input = sys.stdin.readline

n, m = map(int,input().split())
s = [0] #累積和
a = list(map(int,input().split()))
for i in range(n):
    s.append(s[i]+a[i])

mod = [0]*m
for i in s:
    mod[i%m] += 1

ans = 0
for i in mod:
    ans += i*(i-1)//2

print(ans)