// Zero-Sum Ranges

#include <cstdio>
#include <unordered_set>
using namespace std;

unordered_set<long long int> sum_set({});

int main()
{
	int n = 0;
	int num = 0;
	int cnt = 0;
	long long int sum = 0;
	scanf("%d", &n);
	sum_set.clear();
	for(int i=0; i<n; ++i)
	{
		scanf("%d", &num);
		sum += num;
		if(sum_set.find(sum) != sum_set.end())
			++cnt;
		else
			sum_set.add(sum);
	}
	printf("%d\n", cnt);
}