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

my $n = read_line;
my @nums = splited_read_line;

my $dp = [];
say solve();

sub solve {
  my $count = 0;
  for (my $i = $n - 2; $i >= 0; $i--) {
    my $sum = 0;
    for (my $j = $i; $j <= $n - 1; $j++) {
      $sum += $nums[$j];
      if ($sum == 0) {
        $count++;
      }
    }
  }
  $count;
}