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

def bar_M(t):
    return t%m

array = list(map(bar_M,array))
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:
    sums.append(array_sum.count(i))
ans = 0
for i in sums:
    ans+=int((i-1)*i/2)
print(ans)