<?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];
    $sum %= $M;
    $A[$i] = $sum;
}

$count_values = array_count_values($A);

$result = 0;

foreach ($count_values as $k => $v) {
    if ($k === 0) {
        $v++;
    }
    $result += $V * ($v - 1) / 2;
}

// 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";