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
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VII;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
#define PB push_back
map<int, int> m;
int DP[5001];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	VII cuksy(n);
	for(int i = 0; i < n; ++i) cin>>cuksy[i];
	sort(cuksy.begin(), cuksy.end());
	DP[0] = 1;
	int sum = 0;
	int sum_over = 0;
	for(int i = 0; i < n; ++i) {
		sum_over *= 2;
		sum_over %= MOD;
		for(int j = 5000; j >= cuksy[i]-1; --j) {
			if(j + cuksy[i] > 5000 && DP[j]) {
				//sum_over %= MOD;
				sum_over += DP[j];
				sum_over %= MOD;
			} else if(j + cuksy[i] <= 5000) {
				DP[j + cuksy[i]] += DP[j];
				sum += DP[j];
				sum %= MOD;
				DP[j + cuksy[i]] %= MOD;
			}
		}
		
	}
	cout<<(sum + sum_over)%MOD<<"\n";
}