#include <bits/stdc++.h>

#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	int n; cin>>n;
	vector<ll> v(n), w(n+1);
	rep(i,n) cin>>v[i];
	w[0] = 0;
	rep(i,n)
		if (i % 2)
			w[i+1] = w[i] + v[i];
		else
			w[i+1] = w[i] - v[i];
	ll cnt = 0;
	map<ll, int> mp;
	mp[0]++;
	rep(i,n + 1)
	{
		if (!i) continue;
		cnt += mp[w[i]];
		mp[w[i]]++;
	}
	cout << cnt << "\n";
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

constexpr bool typetest = 0;
constexpr int N = 3e5 + 5;
int n;
ll a[N];

void Read()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i],
            a[i] = a[i - 1] + ((i & 1) ? 1 : -1) * a[i];
}

void Solve()
{
    sort(a, a + n + 1);
    ll ans(0);
    for (int i = 0, j = 0; i <= n; ++i)
    {
        while (j <= n && a[i] == a[j])
            ++j;
        ans += 1ll * (j - i) * (j - i - 1) / 2;
        i = j - 1;
    }

    cout << ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t(1);
    if (typetest)
        cin >> t;
    for (int _ = 1; _ <= t; ++_)
    {
        Read();
        Solve();
    }
}