import numpy as np
from itertools import combinations_with_replacement

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

cum_A = np.cumsum(A)
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)