///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           nd(a,b,c)                   mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=2e18;
const int mod=1e9+7;
const int M=3005;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int n;
int a[M],pre[M];

int dp[M][M];

int sum[M],nxt[M];

 main()

{
    fast
    cin>>n;
    f(i,1,n)cin>>a[i],pre[i]=a[i]+pre[i-1];

    rf(k,n,1)
    {
        f(pos,1,n)
        {
            int val=pre[pos-1]%k;

            sum[val]=sub(sum[val],dp[pos][k+1]);

            dp[pos][k]=sum[val];

            int z=pre[n]-pre[pos-1];
            z=z%k;

            if(z==0)dp[pos][k]=(dp[pos][k]+1)%mod;

            if(k!=1){

            val=pre[pos-1]%(k-1);
            nxt[val]=ad(nxt[val],dp[pos][k]);

            }
        }

        f(j,0,k+1)
        {
            sum[j]=nxt[j];
            nxt[j]=0;
        }
    }

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

}




































#include<cstdio>
#define MOD 1000000007
#define MAXK 3000

int n;
long long a[MAXK + 5];
long long s;
int dp[MAXK + 5][MAXK + 5];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    for (int j = n; j >= 2; j--) {
      dp[s % j][j] += dp[s % (j - 1)][j - 1];
      dp[s % j][j] %= MOD;
    }
    dp[0][1] = 1;
    s += a[i];
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[s % i][i];
    ans %= MOD;
  }
  printf("%d\n", ans);
}
