use v5.18;
use warnings;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my ($n, $m) = splited_read_line;
my @sweets = splited_read_line;

my $count = 0;
for my $r (0 .. $n - 1) {
  my $sum = 0;
  for my $l ($r .. $n - 1) {
    $sum += $sweets[$l];
    $count++ if $sum % $m == 0;
  }
}
say $count;
