from itertools import product
import numpy as np

N,M = list(map(int,input().split()))
A = np.array(input().split(),dtype='int64')

C = np.append([0],np.cumsum(A))   
L =[1 for t, i in product(C,C) if i<t and (t - i)%M==0]


print(len(L))