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

typedef long long ll;
#define pb push_back

const int MOD = 1e9 + 7, N = 3e3 + 5;

int add(int x, int y)
{
    x += y;
    while (x >= MOD)
        x -= MOD;
    while (x < 0)
        x += MOD;
    return x;
}

int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> arr(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    vector<vector<int>> dp(n + 1, vector<int>(n + 1)), last(n + 1, vector<int>(n + 1));
    for (int k = 1; k <= n; k++)
    {
        vector<int> div(k + 1, -1);
        div[0] = 0;
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            sum += arr[i] % k;
            sum %= k;
            last[i][k] = div[sum];
            div[sum] = i;
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int k = 1; k <= i; k++)
        {
            int l = last[i][k];
            if (l >= 0)
                dp[i][k] = add(dp[l][k], dp[l][k - 1]);
        }
    }
    int res = 0;
    for (int i = 1; i <= n; i++)
        res = add(res, dp[n][i]);
    cout << res << "\n";
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    vector<vector<ll>> dp(n,vector<ll>(n+1,0));
    vector<vector<ll>> conn(n,vector<ll>(n+1,-1));
    vector<vector<ll>> table(n,vector<ll>(n+1,-1));
    ll asum = 0;
    REP(i,n) {
        asum += a[i];
        FOR(j,1,n) {
            ll ad = asum%j;
            conn[i][j]= table[ad][j];
            table[ad][j]=i;
        }
    }
    dp[0][1]=1;
    FOR(i,1,n-1) {
        dp[i][1]=1;
        FOR(j,2,n) {
            if (conn[i][j]!=-1) {
                // cout << i << " " << j << " " << dp[conn[i][j]][j] << " " << dp[conn[i][j]][j-1] << endl;
                dp[i][j]=(dp[i][j]+dp[conn[i][j]][j])%MOD;
                dp[i][j]=(dp[i][j]+dp[conn[i][j]][j-1])%MOD;
            }
        }
    }
    // REP(i,n){
    //     REP(j,n+1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    ll ans = 0;
    FOR(i,1,n) ans = (ans+dp[n-1][i])%MOD;
    cout << ans << endl;
}