my $N = <STDIN>;
my @A = split(/ /, <STDIN>);
my $tot = 0;
foreach my $i (0..$N-1) {
        my $AiTot = $A[$i];
        foreach my $j ($i+1..$N-1) {
                $AiTot += $A[$j];
                if ($AiTot == 0) {
                        $tot++;
                }
        }
}
print $tot;