import numpy as np
N, M = map(int, input().split())
A = list(map(int, input().split()))
l = np.arange(1,N+1)
ans = 0
for i in range(0, len(l)):
    for j in range(i, len(l)):
        if sum(A[l[i]-1:l[j]]) % M == 0:
            ans += 1
print(ans)