n, m = map(int, input().split())
a = [0] + list(map(int, input().split()))
acs = [0] * (n + 1)

for i in range(1, n + 1):
    acs[i] = acs[i - 1] + a[i - 1]
cnt = 0

for l in range(n):
    for r in range(l, n):
        if (acs[r] - acs[l - 1]) % m == 0:
            cnt += 1
print(cnt)