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

ans =0
for i in range(N):
    for j in range(i,N):
        if i == j:
            if a[i]%M==0:
                ans+=1
        else:
            if sum(a[i:j+1])%M==0:
                ans += 1
print(ans)