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
#include <iostream>
#include <vector>
#include <algorithm>

const long long p = 1000000007;

void count(std::vector<long long>& v, long long& counter, long long n, long long sum, long long i)
{
	while (i < n && v[i] <= (sum + 1))
	{
		++counter;
		counter = counter % p;
		count(v, counter, n, sum + v[i], i + 1);
		++i;
	}
	return;
}

int main()
{
	std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
	long long n;
	std::cin >> n;
	std::vector<long long> v(n);
	for (long long i = 0; i < n; ++i)
		std::cin >> v[i];
	std::sort(v.begin(), v.end());
	long long counter = 0;
	count(v, counter, n, 0, 0);
	std::cout << counter << std::endl;
	return 0;
}