import numpy
ans = 0
n, m = map(int, input().split())
a = numpy.cumsum([0] + [int(i) for i in input().split()])
for i in range(n):
    for j in range(i+1):
        if (a[i+1] - a[j]) % m == 0:
            ans += 1
print(ans)