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
43
#include<bits/stdc++.h>
#define lim 5009

using namespace std;

typedef unsigned int uint;
const int md = 1000000007;
const int l = 5000;
long long t[lim];
int n;
vector<int> v;

int main()
{
	scanf("%d", &n);
	t[0] = 1;
	for(int i = 0;i<n;++i)
	{
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for(uint i = 0;i<v.size();++i)
	{
		int m = min(v[i]-1,l-v[i]+1);//////
		for(int j = 0;j<=m;++j)
		{
			t[l] = (t[l]+t[l-j])%md;
		}
		m = 2*v[i]-1;
		for(int j = l;j>=m;--j)
		{
			t[j] = (t[j]+t[j-v[i]])%md;
		}
	}
	long long wyn = 0;
	for(int i = 1;i<=l;++i)
	{
		wyn = (wyn+t[i])%md;
	}
	printf("%lld\n", wyn);
}