implicit none
integer :: n,m
integer,allocatable :: a(:),b(:)
integer(8) :: s
integer :: i,j

read *,n,m
allocate(a(n))
read *,a

allocate(b(0:n))
b(0) = 0
s = 0
do i = 1, n
   b(i) = mod(b(i-1) + a(i),m)
   do j = 0, i-1
      if (b(j) == b(i)) then
         s = s + 1
      endif
   enddo
enddo

print '(i0)',s
end