#include <bits/stdc++.h>
#define endl '\n'
#define fr first
#define sc second
#define all(v) v.begin(),v.end()
#define unq(v) sort( all(v) ); v.erase( unique( all(v) ), v.end() )
#define bout(x) cout << bitset<sizeof(x)*8>(x) << endl
#define mkp(a,b) make_pair(a,b)
#define gcd(a,b) __gcd(a,b)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using cpl = complex<ld>;
const ld pi = 3.14159265358979323846264338327950288;
const ld tau = 2 * pi;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, ddy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int nx[8] = {1, 2, 2, 1, -1, -2, -2, -1}, ny[8] = {-2, -1, 1, 2, 2, 1, -1, -2};

#define DEBUG

map<pll, ll> mp;
ll arr[300020];
ll pre[300020];

void Main(){
	int n; cin >> n;
	for (int i = 1; i <= n; i++){ cin >> arr[i]; }
	ll ans = 0;
	mp[mkp(0, 0)] = 1;
	for (int i = 1; i <= n; i++){
		pre[i] = arr[i] - pre[i-1];
		pll p = {pre[i], i&1};
		if (mp.count(p) == 0){ mp[p] = 1; }
		else{ mp[p] = mp[p] + 1; }
		pll p1 = {pre[i], i&1}, p2 = {-pre[i], ~i&1};
		ll x1 = mp[p1], x2 = mp[p2];
		ans += x1-1 + x2;
	}
	cout << ans;
}

int main(){
#ifndef DEBUG
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#endif
	cout.setf(ios::fixed);
	cout.precision(0);
	Main();
}

#include <bits/stdc++.h>

using namespace std;
#define int long long

long long MOD =1e9+7;


vector<vector<long long> > m(3e3+10,vector<long long>(3e3+10,-1));
vector<long long> v;
vector<vector<int> > tps;
long long bourrin(int i, int from) {
    if(from == -1) return 0;
    if(m[i][from]!= -1) {
        return m[i][from];
    }
    if(from >= v.size()) {
        return 1;
    }

    long long res = bourrin(i,tps[from][i]);
    if(tps[from][i+1] != -1) {
        res += bourrin(i+1,tps[from][i+1]);
    }
    res%=MOD;
    m[i][from] = res;
    return res;

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    v=vector<long long>(N);
    for(int c=0;c<N;c++) cin>>v[c];

    vector<vector<int> > modulos(N+10,vector<int>(N+10,-2));
    for(int c=0;c<N+10;c++) modulos[c][0]=-1;
    vector<long long> current(N+10,0);

    tps=vector<vector<int> > (N+10,vector<int> (N+10,-1));

    reverse(v.begin(),v.end());

    for(int c=0;c<N;c++) {
        for(int c2=1;c2<=N;c2++){
            current[c2] += v[c];
            current[c2] %= c2;

            if(modulos[c2][current[c2]] != -2) {
                tps[N-1-c][c2] = N-1-modulos[c2][current[c2]];


            }
            modulos[c2][current[c2]]=c;
        }
    }

//    return 0;

    reverse(v.begin(),v.end());

    cout<<bourrin(1,1);

}
