N , M = map(int,input().split())
A =  map(int,input().split())
A = [a for a in A]

partial_sum_list = [0]
partial_sum = 0
res = 0
i = 0
while i < N:
    partial_sum += A[i]
    partial_sum_list.append(partial_sum)
    temp = partial_sum % M
    j = 0
    while j < len(partial_sum_list)-1:
        if temp == (partial_sum_list[j] % M):
            res += 1
        j += 1
    i = i + 1
print(res)