from itertools import accumulate
N, M = map(int, input().split())
A = list(map(int, input().split()))

B = [0] + A
B = list(accumulate(B))

ans = []
cnt = 0
for i in range(1, len(B)):
    for j in range(i):
        if (B[i] - B[j])%M == 0:
            cnt += 1
print(cnt)