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
44
45
46
47
48
49
50
51
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

map<long long, long long> m;
long long over;

//long long m[25000100];
multiset<long long> s;

int main() {
	// your code goes here
	long long n;
	scanf("%lld",&n);
	while(n--)
	{
		long long k;
		scanf("%lld",&k);
		s.insert(k);
	}
	long long maxk = *s.rbegin();
	m[0]=1;
	for_each(s.begin(),s.end(),[&](auto k){
		over*=2;
		over%=1000000007;
		vector<pair<long long, long long>>t;
		for_each(m.rbegin(),m.rend(),[&](auto i){
			if(i.first>=k-1)
			{
				if((i.first+k)>maxk+1)over+=i.second;
				else t.push_back(make_pair(i.first+k,i.second));
				over%=1000000007;
			}
		});
		for_each(t.begin(),t.end(),[&](auto i){
			m[i.first]+=i.second;
			m[i.first]%=1000000007;
		});
	});
	long long sum=over;
	for_each(m.begin(),m.end(),[&](auto i){
	//	printf("[%d]:%d ",i.first,i.second);
		sum+=i.second;
		sum%=1000000007;
	});
	printf("%lld\n",sum-1);
	return 0;
}