<?php

fscanf(STDIN, "%d", $n);
$input = explode(' ', fgets(STDIN));

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

$count = 0;
for ($start = 0; $start < $n; $start++) {
	$sum = 0;
	for ($goal = $start; $goal < $n; $goal++) {
		$sum += $a_n[$goal];
		if ($sum === 0) {
			$count++;
		}
	}
}

echo $count,"\n";
