import numpy as np

n,m = map(int,input().split())
A = list(map(int,input().split()))
B = []
res = 0

for a in A:
    res += a
    B.append(res)
B = np.array(B)

ans = 0
for i in range(n):
    b = B[i:]
    # print(b)
    ans += np.count_nonzero(b%m == 0)
    B -= B[i]

print(ans)