#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long  int ll;
typedef long double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define at(s,pos) *(s.find_by_order(pos))
#define set_ind(s,val) s.order_of_key(val)
long long int M = 1e9 + 7 ;
long long int inf = 9 * 1e18;
const double PI = acos(-1);
//CLOCK
ll begtime = clock();
#define time() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//CLOCK ENDED
ll n, m;
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (deg < 0)
		return 0;
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
//binomial
ll modinv(ll n) {
	return binpow(n, M - 2);
}
void google(ll x) {
	cout << "Case #" << x << ": ";
}
int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> n;
	ll a[n];
	rep(i, n) {
		cin >> a[i];
	}
	//even length ke liye ending at even pos

	v<ll> b;
	for (i = 1; i < n; i += 2) {
		b.pb(a[i] - a[i - 1]);
	}
	//number of segments with sum=0
	map<ll, ll> ma;
	ll ans = 0;
	ll sum = 0;
	for (auto u : b) {
		sum += u;
		ans += ma[sum];
		ma[sum]++;
	}
	ans += ma[0];

	//even length ke liye ending at odd pos
	b.clear();
	for (i = 2; i < n; i += 2) {
		b.pb(a[i] - a[i - 1]);
	}
	ma.clear();
	sum = 0;
	for (auto u : b) {
		sum += u;
		ans += ma[sum];
		ma[sum]++;
	}
	ans += ma[0];

	//odd length ending at even pos
	ma.clear();
	sum = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			y = sum - a[i];
			if (y == 0) ans++;
			ans += ma[y];
		}
		else {
			sum += (a[i] - a[i - 1]);
			ma[sum]++;
		}
	}
	ma.clear();
	sum = 0;
	for (i = 1; i < n; i++) {
		if (i % 2) {
			y = sum - a[i];
			// cout << y << ' ';
			if (y == 0) ans++;
			ans += ma[y];
		}
		else {
			sum += a[i] - a[i - 1];
			ma[sum]++;
		}
	}
	cout << ans;



	return 0;
}









#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef long long int ll;
typedef unsigned long long int ull;

typedef long double lld;

using namespace std;
using namespace std::chrono;

const ll mod = 1'000'000'000ll + 7;
//const ll mod = 998'244'353ll;

const ll inf = 1'000'000'000'000'000'000ll;

const long double eps = 1e-15;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    ll n;
    cin >> n;

    vector<ll> a(n + 1);
    for (ll i = 1; i <= n; i++) {
        cin >> a[i];
        if (i % 2) {
            a[i] *= -1;
        }
    }

    vector<ll> ps(n + 1);
    for (ll i = 1; i <= n; i++) {
        ps[i] = ps[i - 1] + a[i];
    }

    map<ll, ll> q;
    for (ll i = 1; i <= n; i++) {
        q[ps[i]] += 1;
    }

    ll R = 0;
    for (ll i = 1; i <= n; i++) {
        R += q[ps[i - 1]];
        q[ps[i]] -= 1;
    }

    cout << R << endl;

    return 0;
}