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>

using namespace std;

const int N = 5007;
const int M = 5000;
const int MX = 1e9 + 7;

int n;
int in[N];
int dp[N];

void add(int &a, int b) {
	a += b;
	if(a >= MX)
		a -= MX;
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &in[i]);
	sort(in + 1, in + n + 1);
	
	dp[0] = 1;
	for(int i = 1; i <= n; ++i) {
		for(int j = M; j >= in[i] - 1; --j)
			add(dp[min(j + in[i], M)], dp[j]);
	}
	
	int ans = 0;
	for(int i = 1; i <= M; ++i)
		add(ans, dp[i]);
	printf("%d\n", ans);
	return 0;
}