#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 3005;

LL f[N][N], a[N];
LL pre[N];
LL g[N];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        pre[i] = pre[i - 1] + a[i];
    }
    LL ans = 0;
    f[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++) g[j] = 0;
        for (int j = 0; j <= n; j++) {
            f[i][j] = g[pre[j] % i] % mod;
            g[pre[j] % i] += f[i - 1][j];
        }
        ans += f[i][n];
    }
    cout << ans % mod << endl;
    return 0;
}

// ＵＴＦ−８

#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using lc = complex<double>;
template <class T>
bool complex_comparator(const complex<T> &a, const complex<T> &b) {
 return real(a) == real(b) ? imag(a) < imag(b) : real(a) < real(b);
}

/* #include<atcoder/all> */
/* using namespace atcoder; */

template<class T>bool chmax(T &a, const T &b) { return (a<b ? (a=b,1) : 0); }
template<class T>bool chmin(T &a, const T &b) { return (a>b ? (a=b,1) : 0); }

int main(void) {
    constexpr ll MOD = 1 ? 1e9+7 : 998244353;
    const double PI = acos(-1);
    constexpr double eps = 1e-5;
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    if(1) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        for(auto &e: a) cin >> e;

        vector<ll> d(n, 1);

        ll res = 0;

        res++; // 全部一緒

        for(ll i=2; i<=n; i++) {
            map<ll,vector<ll>> cu;
            vector<ll> e(n);

            {
                ll x = 0;
                for(ll j=0; j<n; j++)
                    cu[((x+=a[j])%=i)].push_back(j);
            }

            for(auto &[k, v]: cu) {
                ll x = 0;
                for(ll j=0; j<v.size(); j++) {
                    ll t2 = v[j];
                    (e[t2] += x) %= MOD;
                    if(t2 == n-1) (res += x) %= MOD;
                    x += d[v[j]];
                }
            }
            // for(auto &x: e) cerr << x << ' '; cerr << endl;
            swap(d, e);
        }
        cout << res << endl;
    }
    return 0;
}