#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef double db;
#define fi first
#define se second
const int MAXN=2e5+10;
int a[MAXN], n, pa[MAXN], cnt;
set<int> s;
inline void pre(int siz) { iota(pa+1, pa+1+siz, 1); cnt=siz; }
int find(int u) { return u==pa[u]?u:(pa[u]=find(pa[u])); }
inline bool isunion(int u,int v) { return find(u)==find(v); }
inline void merge(int u,int v) { if( isunion(u, v) ) return ; pa[find(u)]=find(v); --cnt; }
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    pre(2e5);
    cnt=0;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        if(s.find(a[i])!=s.end()) continue;
        s.insert(a[i]);
        ++cnt;
    }
    int now=cnt;
    for(int l=1, r=n;l<r;++l, --r) merge(a[l], a[r]);
    cout<<now-cnt;
    cout.flush();
    return 0;
}
#include<bits/stdc++.h>
#define MAXN 300005
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[MAXN];
map<ll,int> cnt;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll cur=0,ans=0;
    cnt[cur]++;
    for(int i=1;i<=n;i++)
    {
        if(i&1) cur+=a[i]; else cur-=a[i];
        ans+=cnt[cur];
        cnt[cur]++;
    }
    printf("%lld\n",ans);
    return 0;
}