#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll n,a[300001],memo[300001] = {},ans = 0,tmp,cnt = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    memo[0] = a[0];
    memo[n] = 0;
    for(int i = 1; i < n; i++){
        memo[i] = a[i] - memo[i - 1];
    }
    for(int i = 0; i < n; i++){
        if(i % 2 == 1){
            memo[i] *= -1;
        }
    }
    sort(memo,memo+n+1);
    tmp = memo[0];
    for(int i = 0; i < n+1; i++){
        while(memo[i] == tmp && i <= n){
            cnt++;
            i++;
        }
        tmp = memo[i];
        ans += (cnt*(cnt-1))/2;
        cnt = 0;
        i--;
    }

    cout << ans;
}
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ll long long
inline ll read(){ll x;scanf("%lld",&x);return x;}
ll Abs(ll x){if(x<0)return -x;return x;}

int main()
{
	ll n=read();
	__int128 L=0,R=n+1;
	while(L<R){
		__int128 Mid=(L+R+1)>>1;
		if((__int128)(1+Mid)*Mid/2<=n+1) L=Mid;
		else R=Mid-1;
	}
	cout<<n-(ll)L+1;
	return 0;
}