#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define ROF(i,a,b) for(int i=(a); i>=(b); --i)
#define pb push_back
#define eb emplace_back
#define SZ(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define make_unique(a) sort(all((a))), (a).erase(unique(all((a))),(a).end())
#define x first
#define y second
#define MP make_pair
#define MT make_tuple
#define debug(x) cout << #x << " = " << x << endl
#define debug2(x,y) FOR(i,1,y) cout << "##"; cout << #x << " = " << x << endl

using namespace std;

typedef long long i64;
typedef tuple<int,int,int> iii;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

int readInt(){ int a; scanf("%d",&a); return a; }
i64 readLong(){ i64 a; scanf("%lld",&a); return a;}
void readString(char *s){ scanf(" %s",s); }

const int mod = 998244353;
int add(int a, int b){ return ((a+=b)>=mod)?a-mod:a; }
void adding(int &a, int b){ a = add(a,b); }
int mul(int a, int b){ return a*1ll*b%mod; }
int pw(int a, int b){
	int res = a, ans = 1;
	for(int i=1;i<=b;i<<=1,res=mul(res,res)){
		if(i&b) ans = mul(ans, res);
	}
	return ans;
}

const int N = 600005;
vector<i64> comp;

i64 dp[N], r[N];
int cnt[2][N];

int main(){
	int n = readInt();
	FOR(i, 1, n){
		dp[i] = readLong();
		dp[i] -= dp[i-1];
		//printf("[%lld] ",dp[i]);
		comp.eb(dp[i]);
		comp.eb(-dp[i]);
	}
	comp.eb(0);
	make_unique(comp);
	FOR(i, 0, n){
		r[i] = upper_bound(all(comp), -dp[i])-comp.begin();
		dp[i] = upper_bound(all(comp),dp[i])-comp.begin();
	}
	i64 ans = 0;
	cnt[0][dp[0]]++;
	FOR(i, 1, n){
		int nw = (i&1);
		ans += cnt[nw][dp[i]]+cnt[nw^1][r[i]];
		cnt[nw][dp[i]]++;
	}
	printf("%lld",ans);
	return 0;
}
// 1

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

map<ll,int> mp[2];

int main(){
    int n; cin >> n;
    vector<int> a(n);
    ll pre=0;
    mp[1][0]++;
    ll ans = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        pre = a[i]-pre;
        ans += mp[i&1][pre];
        ans += mp[(i+1)&1][-pre];
        mp[i&1][pre]++;
    }
    cout << ans << endl;
    return 0;
}