line = raw_input()
n, m = [int(s) for s in line.split(' ')]
line = raw_input()
a = [int(s) for s in line.split(' ')]
aa = [0]
for i in range(0, n):
    aa.append(aa[i] + a[i])

ret = 0
for i in range(1, n + 1):
    az = zip(aa, aa[i:])
    for x, y in az:
        if (y - x) % m == 0:
            ret += 1

print ret

