from itertools import combinations_with_replacement

N, M = map(int, input().split())
A = [0]
A.extend([int(a) for a in input().split()])

cum_A = [0] * (N + 1)
for i in range(1, N + 1):
    cum_A[i] = cum_A[i - 1] + A[i]

count = 0
for l, r in combinations_with_replacement(range(1, N + 1), 2):
    num = cum_A[r] - cum_A[l - 1]
    if num % M == 0:
        count += 1
print(count)
