//#include<stdlib.h>
#include"include/io.h"
#include"include/lib.h"

#undef long
#define long() long long int

int n, i;
long b[200001];
long ans, now;
char f;

int main(){
	n = nextInt();
	b[0] = 0;
	for(i=0; i<n; i++){
		b[i+1] = b[i] + nextInt();
	}
	qsort(b, n+1, sizeof(long), compare_long);
	for(i=0; i<n; i++){
		if(b[i+1]==b[i]){
			if(f){now++;}
			else{now=2; f=1;}
		}else{
			if(f){ans+=now*(now-1)/2; f=0;}
		}
	}
	if(f){ans+=now*(now-1)/2; f=0;}
	printLong(ans); println();
}
