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
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define IOS cin.tie(0); ios_base::sync_with_stdio(0)
 
using ll = long long;
using namespace std;

const int MOD = 1e9 + 7;
const int N = 5050;

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

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	sort(a, a + n);
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i)
		for (int s = 0; s <= 5000; ++s) {
			dp[i + 1][s] = (dp[i + 1][s] + dp[i][s]) % MOD;
			if (a[i] <= s + 1) {
				int ns = min(5000, s + a[i]);
				dp[i + 1][ns] = (dp[i + 1][ns] + dp[i][s]) % MOD;
			}
		}
	int res = 0;
	for (int i = 1; i <= 5000; ++i)
		res = (res + dp[n][i]) % MOD;
	printf("%d\n", res);
	return 0;
}