<?php
    list($n, $m) = explode(" ", fgets(STDIN));
	$aArray = explode(" ", fgets(STDIN));
	
	$counter = 0;
	for($r = 1; $r <= $n; $r++){
      $sum = 0;
      for($i = 0; $i < $r; $i++){
        $sum += $aArray[$i];
      }
      $counter += ($sum % $m == 0);
      for($s = 0; $s < $n - $r; $s++){
        $sum += $aArray[$s + $r]; 
        $sum -= $aArray[$s];
        $counter += ($sum % $m == 0);
      }
    }
	echo $counter;

