#!/usr/bin/env python3

[N, M] = [int(x) for x in input().split(" ")]
A = [int(x) for x in input().split(" ")]

ret = 0
for l in range(0, N):
    Sum = 0
    for r in range(l, N):
        Sum += A[r]
        if Sum % M == 0:
            ret += 1
print(ret)
