<?php
$n = trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));

for ($i = 0; $i < $n; $i++) {
    $a[$i] = (int)$a[$i];
}

$c = 0;

for ($i = 0; $i < $n; $i++) {
    $sum = $a[$i];
    for ($j = $i + 1; $j < $n; $j++) {
        $sum = $sum + $a[$j];
        if ($sum === 0) {
            $c++;
        }
    }
}

echo $c . PHP_EOL;