#!/usr/bin/env perl
use strict;
use warnings;

my $N = <>;
my @A = split(' ', <>);

my $count=0;

for my $i (0 .. $N-2) {
    my $buf = $A[$i];
    for my $j ($i+1 .. $N-1) {
        $buf += $A[$j];
        $count++ if $buf == 0;
    }
}

print $count;