implicit none
integer :: n,m
integer,allocatable :: a(:),res(:),cnt(:)
integer(8) :: s
integer :: i,j,nres,b
logical :: flg

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

allocate(cnt(0:n))
allocate(res(0:n))

res(:) = -1
res(0) = 0
cnt(:) = 0
cnt(0) = 1
nres = 0
b = 0
s = 0
do i = 1, n
   b = mod(b + a(i),m)
   flg = .false.
   do j = 0, nres
      if (res(j) == b) then
         s = s + cnt(j)
         cnt(j) = cnt(j) + 1
         flg = .true.
         exit
      endif
   enddo
   if (.not. flg) then
      nres = nres + 1
      res(nres) = b
      cnt(nres) = 1
   endif
enddo

print '(i0)',s
end