n,m = map(int,input().split(" "))
def bar_M(t):
    return int(t)%m
array = list(map(bar_M,input().split(" ")))

array_sum = [0 for i in range(n+1)]
for i in range(1,n+1):
    array_sum[i] = (array_sum[i-1] + array[i-1])%m

nums = set(array_sum)
sums = []
for i in nums:
    p = array_sum.count(i)
    if p > 1:
        sums.append(array_sum.count(i))
ans = 0
for i in sums:
    ans+=int((i-1)*i/2)
print(ans)