#include<bits/stdc++.h>

using namespace std;

#define int long long
#define pb push_back
#define ppb pop_back
#define mp make_pair
using pi = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vector<int> >;
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()

//const int inf = 9e18;
const int NUM=1000030;
const int N = 10000000;
vector<int> lp, sieve;
vector<int> pr;
void primefactor();
int binpow(int a, int b);
int binpow(int a, int b, int mod);
int gcd(int a, int b);
int lcm (int a, int b);
bool comp(int a, int b);
int inversemod(int a, int mod);
void calc_sieve();

int mod1=1e9+7;

void test()
{
    int n;
    cin>>n;
    vi arr(n+1);
    for(int i=1;i<=n;i++) cin>>arr[i];
    vvi modtaken(n+1, vi(n+1));
    int sum=0;
    for(int i=1;i<=n;i++) 
    {   
        sum+=arr[i];
        for(int j=1;j<=n;j++) modtaken[j][i]=sum%j;
    }
    // for(int i=1;i<=n;i++) 
    // {
    //     for(int j=1;j<=n;j++) cerr<<modtaken[i][j]<<" ";
    //     cerr<<endl;
    // }
    // cerr<<endl;
    vvi leftelement(n+1, vi(n+1, -1));
    for(int i=1;i<=n;i++) 
    {
        map<int, int> ele;
        ele.clear();
        for(int j=1;j<=n;j++) 
        {
            if(ele.count(modtaken[i][j])) leftelement[i][j]=ele[modtaken[i][j]];
            ele[modtaken[i][j]]=j;
        }
    }
    vvi dp(n+1, vi(n+1, 0));
    for(int j=1;j<=n;j++) dp[1][j]=1;
    for(int i=2;i<=n;i++) 
    {
        for(int j=2;j<=n;j++) 
        {
            if(leftelement[i][j]==-1) continue;
            dp[i][j]+=dp[i-1][leftelement[i][j]];
            dp[i][j]%=mod1;
            dp[i][j]+=dp[i][leftelement[i][j]];
            dp[i][j]%=mod1;
        }
    }
    // for(int i=1;i<=n;i++) 
    // {
    //     for(int j=1;j<=n;j++) cerr<<dp[i][j]<<" ";
    //     cerr<<endl;
    // }
    // cerr<<endl;
    
    // for(int i=1;i<=n;i++) 
    // {
    //     for(int j=1;j<=n;j++) cerr<<leftelement[i][j]<<" ";
    //     cerr<<endl;
    // }
    // cerr<<endl;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=dp[i][n];
        ans%=mod1;
    }
    cout<<ans<<endl;
}

signed main()
{
//    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--) test();
    return 0;
}

//    1. Take care of the corner cases, write one or two tests that seem to be the cases.
//    2. Check the bounds on the intput and decide the algorithm.
//    3. Make the test cases for the bounds, try to include 0, 1, 2 cases in the new test cases, and if possible, scale the cases.
//    4. Check for overflow and the array bounds carefully, always take care of the decreasing loop.

void calc_sieve() //credits: Anish_Sofat
{
    sieve.resize(NUM+1,0);
    for (int x = 2; x <= NUM; x++)
        {
            if (sieve[x]) continue;
            for (int u = x; u <= NUM; u += x)
            {
                    sieve[u] = x ;
            }
        }
}

void primefactor()
{
    lp.resize(N+1,0);
    for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}

int binpow(int a, int b)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int binpow(int a, int b, int mod)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}

int gcd(int a, int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}

int lcm (int a, int b)
{
    return ((a / gcd(a, b)) * b);
}

bool comp(int a, int b)
{
    return a>b;
}

int inversemod(int a, int mod)
{
    return binpow(a,mod-2, mod);
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; ++i)
const int N = 5e3 + 5;
const int P = 1e9 + 7;
int n, ans, a[N], sum[N], f[N][N], g[N][N];

signed main () {
	cin >> n;
	rep(i, 1, n) cin >> a[i], sum[i] = sum[i - 1] + a[i];
	f[0][0] = g[0][0] = 1;
	rep(i, 1, n) {
		rep(j, 1, i) f[i][j] = g[sum[i] % j][j - 1];
		rep(j, 1, i) g[sum[i] % (j + 1)][j] = (g[sum[i] % (j + 1)][j] + f[i][j]) % P;
	}
	rep(i, 1, n) ans = (ans + f[n][i]) % P;
	cout << ans;
	return 0;
}