<?php
 
function input_and_explode() {
    $input_line = trim(fgets(STDIN));
    return explode(" ", $input_line);
}

list($N, $M) = input_and_explode();

$A = input_and_explode();
$sum = 0;
for ($i = 0, $len = count($A); $i < $len; $i++) {
    $sum += $A[$i];
    $A[$i] = $sum;
}

$result = 0;

for ($r = 1; $r <= $N; $r++) {
    for ($l = 1; $l <= $r; $l++) {
        if ($l === 1) {
            $A_sliced_sum = $A[$r - 1] - 0;
        } else {
            $A_sliced_sum = $A[$r - 1] - $A[$l - 2];
        }
        if ($A_sliced_sum % $M === 0) {
            $result++;
        }
    }
}

echo "$result\n";