///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<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
struct MB{
    int x;
    MB(int _x=0):x(_x){}
    void operator +=(const MB& o){ *this = *this + o; }
    void operator -=(const MB& o){ *this = *this - o; }
    void operator *=(const MB& o){ *this = *this * o; }
    MB& operator ++(){ return *this = *this + MB(1); }
    MB operator ++(int){ MB r=*this; ++(*this); return r; }
    MB operator +(const MB& o){ return x+o.x >=mod ? x+o.x-mod : x+o.x; }
    MB operator -(const MB& o){ return x-o.x < 0 ? x-o.x+mod : x-o.x; }
    MB operator *(const MB& o){ return int(1ll*x*o.x%mod); }
    operator int(){return x;}
    friend ostream& operator<< (ostream& os, MB& o) { return os << o.x; }
    friend istream& operator>> (istream& is, MB& o) { return is >> o.x; }
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    using ll = long long;
    int n;cin>>n;
    vector<ll>a(n),p(n+1);
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=0;i<n;++i)p[i+1] = a[i] + p[i];
    vector<vector<MB>>dp(2,vector<MB>(n+1));
    //dp[i][j] - #formas de fazer i grupos em [0..j)
    dp[0][0] = 1;
    MB ans = 0;
    for(int i=1,o=1;i<=n;++i,o^=1){
        vector<MB>s(n);
        for(int j=0;j<=n;++j){
            //dp[i][j] = somatorio de dp[i-1][x], soma( [x,j) ) == 0 mod i x < j
            //dp[i][j] = somatorio de dp[i-1][x], p[j] == p[x] mod i x < j
            dp[o][j] = s[ p[j] % i ];
            s[p[j] % i] += dp[o^1][j];
        }
        ans += dp[o][n];
    }
    cout<<ans<<'\n';
    return 0;
}
