from math import ceil

N,M=map(int,input().split())
A=list(map(int,input().split()))

ans=0
for i in range(ceil(N/2)):
    head=0
    for j in range(i,N-i):
        head += A[j]
        ans += int(head%M==0)
    for j in range(i,N-i-1):
        head -= A[j]
        ans += int(head%M==0)
        
print(ans)