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
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 5000;
const int mod = 1e9+7;

int dp[MAXN+5][MAXN+5];

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;

	vector<int> t(n+1);
	for(int i=1;i<=n;i++)
		cin >> t[i];
	sort(t.begin()+1, t.end());

	dp[0][0] = 1;

	for(int i=1;i<=n;i++){
		for(int j=0;j<=MAXN+1;j++)
			dp[i][j] = dp[i-1][j];

		for(int j=t[i]-1;j<=MAXN+1;j++){
			dp[i][min(MAXN+1,t[i]+j)] += dp[i-1][j];
			dp[i][min(MAXN+1,t[i]+j)] %= mod;
		}
	}

	int sum = 0;
	for(int i=1;i<=MAXN+1;i++){
		sum += dp[n][i];
		sum %= mod;
	}

	cout << sum << "\n";

	return 0;
}