from numpy import*

def section_sum(numbers,separate):
    sep1=array(numbers[separate:],dtype=int)
    sep2=array(numbers[:-separate],dtype=int)
    sep3=sum(numbers[:separate])
    return insert(sep3+cumsum(sep1-sep2),0,sep3)

n,m,*a=map(int,open(0).read().split())
print(sum(sum(section_sum(a,i)%m==0)for i in range(1,n+1)))