import numpy as np

n, m = map(int, input().split())
A = np.array(list(map(int, input().split())))

ans = 0
for l in range(n):
    for r in range(l, n):
        if A[l:r + 1].sum() % m == 0:
            ans += 1
print(ans)