#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <boost/math/common_factor_rt.hpp>

#define ll long long

using namespace std;

int a[200050];
int r[200050];

int main() {
	ll n;
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	r[0] = 0;

	for (int i = 0; i <= n; i++)
	{
		r[i + 1] = r[i] + a[i];
	}

	sort(r, r + n);

	for (int i = 0; i <= n; i++)
	{
		if (r[i] == r[i + 1]) {
			ans++;
		}
		if (r[i] == r[i + 2]) {
			ans++;
		}
	}

	cout << ans << endl;
}

int dsum(int a) {
	int ans = 0;
	while (a != 0) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}
