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
#include <cstdio>
#include <algorithm>
using namespace std;

int tab[5005];
int a[5005];
int p = 1000000007;

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	tab[0] = 1;
	for (int i = 0; i < n; i++){
		for (int j = 5000; j >= a[i] - 1; j--){
			int l = min(j + a[i], 5000);
			tab[l] += tab[j];
			tab[l] %= p;
		}
	}
	int r = 0;
	for (int i = 1; i <= 5000; i++){
		r += tab[i];
		r %= p;
	}
	printf("%d\n", r);
}