#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using ordered_set = tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

const ll MOD = 1e9+7;
const ll INF = 1e18;
const ll N = 2e5+1;

#define S second
#define F first
#define vt vector
#define rep(i, st, en) for(ll i = (st); i < (en); ++i)
#define repr(i, en, st) for(ll i = (en); i >= (st); --i)


int main() {
	fastio();
	
	ll n;
	cin >> n;

	vt<ll> a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}

	vt<vt<ll>> dp(n+1, vt<ll>(n+1, 0)); 

	/**
	 * 	dp[i][j]:
	 * 		i: which bag is being filled [1...n]
	 * 		j: currently starting the bag at which index ?
	 * 	Answer:
	 * 		dp[1][1]
	 */

	vt<ll> ps(n+1);
	ps[0] = 0;

	rep(i, 1, n+1) {
		ps[i] = ps[i-1] + a[i-1];
	}

	vt<vt<ll>> mult(n+1, vt<ll>(n+1, -1)); // stores index for the next multiple
	rep(i, 1, n+1) {
		vt<ll> modu(i, -1);
		ll sum = 0;
		repr(j, n, 1) {
			sum += a[j-1];
			sum %= i;

			// if (i == 2) {
			// 	cerr << j << " << j \t" << modu[sum] << " << modu \t" << sum << " sum \n";
			// }

			if (modu[sum] != -1) {
				mult[i][j] = modu[sum];
			}
			modu[sum] = j;

		}
	}

	// rep(i, 1, n+1) {
	// 	cerr << "i: " << i << ": \n";
	// 	rep(j, 1, n+1) {
	// 		cerr << mult[i][j] << "\t";
	// 	}
	// 	cerr << "\n";
	// }

	repr(j, n, 1) {

		//cerr << "j = " << j << "\n";
		rep(i, 1, n+1) {

			if (mult[i][j] != -1) {
				dp[i][j] = (dp[i][j] + dp[i][mult[i][j]] + (i+1 <= n ? dp[i+1][mult[i][j]] : 0)) % MOD;
			}
			else {
				if ((ps[n]-ps[j-1]) % i == 0) {
					dp[i][j] = 1;
				}
			}
			
			//cerr << dp[i][j] << " " << mult[i][j] << "\n";
		}


	}



	cout << dp[1][1] << "\n";

	

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

int main(){
	
	int n;
	cin>>n;
	
	vector<ll> lista(n+1);
	for(int i = 1; i<=n; i++){
		cin>>lista[i];
	}
	
	vector<vector<ll> > dp(n+1, vector<ll>(n+1, 0));
	
	for(int i = 1; i<=n; i++){
		dp[i][1] = 1;
	}
	
	for(int i = 2; i<=n; i++){
		vector<ll> resto(i, 0);
		ll sum = 0;
		for(int j = 1; j<=n; j++){
			sum = (sum + lista[j])%i;
			dp[j][i] = (dp[j][i] + resto[sum%i])%MOD;
			resto[sum%i] = (resto[sum%i] + dp[j][i-1])%MOD;
		}
	}
	
	ll res = 0;
	for(int i = 1; i<=n; i++){
		res = (res + dp[n][i])%MOD;
	}
	
	cout<<res<<"\n";
	
	return 0;
}
