#include<iostream>
#include<algorithm>
#define int long long
using namespace std;

const int maxm = 3e3 + 5;
const int mod = 1e9 + 7;

int ms[maxm][maxm];
int d[maxm][maxm];     //d[i][j]表示前i个数分成j段的方案数
int sum[maxm];
int a[maxm];
int n;

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    for (int i = 1; i <= n; i++) {
        d[i][1] = 1;
        for (int j = 2; j <= n; j++) {
            int t = sum[i] % j;
            d[i][j] = ms[j][t];
        }
        for (int j = 2; j <= n; j++) {
            int t = sum[i] % j;
            ms[j][t] = (ms[j][t] + d[i][j - 1]) % mod;
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) ans = (ans + d[n][i]) % mod;
    cout << ans << "\n";
}
signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    solve();
    return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;

int get() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}

const int N = 3e5 + 5;
int n, a[N], b[N], sum[N], top;
map<int, int> cnt[2];

signed main() {
	n = get();
	for(int i = 1; i <= n; i++) a[i] = get();
	sum[1] = a[1];
	for(int i = 2; i <= n; i++) sum[i] = sum[i - 2] + a[i];
	cnt[0][0]++, cnt[1][0]++;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += cnt[i & 1][sum[i] - sum[i - 1]];
		cnt[i & 1][sum[i] - sum[i - 1]]++;
	}
	cnt[0].clear(), cnt[1].clear();
	for(int i = 1; i <= n; i++) {
		ans += cnt[i & 1][sum[i] - sum[i - 1]];
		cnt[i & 1 ^ 1][sum[i - 1] - sum[i]]++;
	}
//	for(int i = 1; i <= n; i += 2) printf("%lld: %lld\n", i, sum[i] - sum[i - 1]);
//	for(int i = 2; i <= n; i += 2) printf("%lld: %lld\n", i, sum[i] - sum[i - 1]);
	printf("%lld\n", ans);
	return 0;
}
