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

const int N = 5005;
const long long mod = 1e9 + 7;
const int D = 5001;

int n;
int tab[N];
long long spos[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &tab[i]);
	}
	sort(tab + 1, tab + n + 1);
	spos[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = D; j >= tab[i] - 1; j--) {
			int ind = min(D, j + tab[i]);
			spos[ind] = (spos[ind] + spos[j]) % mod;
//			if (spos[ind] != 0) {
//				cout << i << " " << j << " " << spos[ind] << " " << spos[j] << endl;
//			}
		}
	}
	long long res = 0;
	for (int i = 1; i <= D; i++) {
		res = (res + spos[i]) % mod;
	}
	printf("%lld\n", res);
}