#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 0;
	vector<int> A;
	map<int,int> mp;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		if(i%2 == 0) A[i] *= -1;
	}
	
	mp[0] = 1;
	for(int i = 0, sum = 0; i < N; i++){
		sum += A[i];
		ans += mp[sum];
		// cout<<"sum = "<<sum<<" += "<<A[i]<<" "<<mp[sum]<<endl;
		
		mp[sum]++;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vi a(n + 1);
	map<ll, int> wys;
	ll suma = 0;
	ll res = 0;
	wys[0] = 1;
	rep(i, 0, n) {
		cin >> a[i];
		if ((i&1) == 0) {
			suma += a[i];
		} else {
			suma -= a[i];
		}
		// printf("suma is :%d, adding: %d\n", suma, wys[suma]);
		res += wys[suma];
		++wys[suma];
	}
	cout << res << endl;
}