import numoy as np
N,M = list(map(int,input().split()))
A = input().split()

count = 0
A = np.array(A,dtype='int64')
B = np.cumsum(A)
C = np.append([0],B)

L = [1 for i in range(len(C)) for t in range(len(C)) if i<t and (C[t] - C[i])%M==0]
print(len(L))