<?php
//$n = 10000;
fscanf(STDIN, "%d", $n);
$input = explode(' ', fgets(STDIN));

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

$memo = [];
$count = 0;
for($i = 0; $i < $n; $i++) {
	$count += $memo[-$a_n[$i]] ?? 0;
	$newMemo = [$a_n[$i] => 1];
	foreach($memo as $key => $value) {
		$newMemo[$key + $a_n[$i]] += $value;
	}
	$memo = $newMemo;
}
echo $count,"\n";