import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long n = read.to!long;
	long[] as = readln.chomp.split.to!(long[]);
	
	long sum = 0;
	long[long] xs;
	xs[sum] = 1;
	foreach(a; as){
		sum += a;
		if(sum in xs) xs[sum] += 1;
		else xs[sum] = 1;
		}
	
	debug xs.writeln;
	
	long ans;
	foreach(k; xs.keys){
		auto v = xs[k];
		ans += v * (v - 1) / 2;
		}
	
	ans.writeln;
	}