#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> FindDiv(ll num) {
	vector<ll> res;
	for (ll i = 1; i * i <= num; ++i) 
		if (num % i == 0) res.push_back(i);
	for (int i = res.size() - 1; i >= 0; --i) {
		if (res[i] * res[i] == num) continue;
		res.push_back(num / res[i]);
	}
	return res;
}
int main() {
	ll n; scanf("%lld", &n);
	n *= 2;
	auto res = FindDiv(n);

	int ans = 0;
	for (auto i : res) {
		ll cur = n / i;
		if (abs(cur - i + 1) % 2 == 0)++ans;
	}
	printf("%d", ans);
}
#include <bits/stdc++.h> 
using namespace std;

#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;

#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 300005

int n;
int a[MAXN];
ll b[MAXN];
ll ans;
ll sum[2];
map<ll, int> mp[2];

int main() {
	scanf("%d", &n);
	REP (i, 0, n) {
		scanf("%d", &a[i]);
	}
	b[0] = a[0];
	REP (i, 1, n) {
		b[i] = a[i] - b[i - 1];
	}
	REP (i, 0, n + 1) {
		ans += mp[i % 2][b[i]];
		sum[i % 2] += a[i];
		sum[(i + 1) % 2] -= a[i];
		REP (j, 0, 2) {
			mp[j][sum[j]]++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}
