1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 5050;
const int mod = 1000000007;

int n;
int a[N];
int dp[N][N];

int main() {
	scanf("%d", &n);
	FOR(i,n) scanf("%d", &a[i]);
	sort(a,a+n);
	int S = a[n-1];
	if (a[0]>1) {
		printf("0\n");
		return 0;
	}
	dp[0][0] = 2;
	dp[0][1] = 1;
	for (int i = 1; i < n; i++) {
		for (int s = 0; s <= S; s++) {
			dp[i][s] = dp[i-1][s];
		}
		for (int t = 0; t <= S; t++) {
			dp[i][t] += dp[i-1][max(a[i]-1,t-a[i])];
			if (dp[i][t] >= mod) dp[i][t] -= mod;
		}
		//cerr << i << " : ";
		//for (int s = 0; s <= S; s++) cerr << dp[i][s] << " ";
		//cerr << "\n";
	}
	printf("%d\n", (dp[n-1][0]+mod-1)%mod);
	return 0;
}