import numpy
n, m = map(int, input().split())
a = numpy.array([0] + list(map(int, input().split())), dtype=numpy.float64)

acs = numpy.cumsum(a)
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)