#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int p=1e9+7;
int n,ans,f[3010][3010],sum[3010];
ll a[3010],s[3010];
int main(){
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;i++)scanf("%lld",&a[i]),s[i]=s[i-1]+a[i];
	f[0][0]=1;
	for(j=1;j<=n;j++){
	  for(i=0;i<j;i++)sum[i]=0;
	  for(i=0;i<=n;i++){
	    f[i][j]=sum[s[i]%(ll)j];
		sum[s[i]%(ll)j]=(sum[s[i]%(ll)j]+f[i][j-1])%p;
	  }
	}
	for(j=1;j<=n;j++)ans=(ans+f[n][j])%p;
	cout<<ans;
	return 0;
}
/*input
12
5 2
5 6
1 2
9 7
2 7
5 5
4 2
6 7
2 2
7 8
9 7
1 8

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=4e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    a%=MOD;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
vector<int> v[maxn];
bool vis[maxn];
int cnt=0;
int num=0;
void dfs(int u){
    vis[u]=1;
    num++;
    for(int x:v[u]){
        if(!vis[x]){
            ++cnt;
            dfs(x);
        }
        else ++cnt;
    }
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    set<int> s;
    REP(i,n){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        s.insert(a),s.insert(b);
        v[a].pb(b);
        v[b].pb(a);
    }
    int ans=sz(s);
    for(auto x:s){
        if(!vis[x]){
            cnt=num=0;
            dfs(x);
            if(cnt==2*(num-1)) --ans;
        }
    }
    cout<<ans;
}