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 <iostream>
#include <map>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>

using ull = unsigned long long;
const ull p = 1000000007;
int result = 0;
int n;
std::vector<int> candies;
std::vector<int> subset;

void subsets(int index, int sum) 
{
    for (int i = index; i < candies.size(); i++) 
	{
	    if(candies[i] > sum + 1)
			break;
	    ++result;
        subset.push_back(candies[i]); 
        subsets(i + 1, sum + candies[i]); 
        subset.pop_back(); 
    }
} 
  
int main()
{
    std::iostream::sync_with_stdio(false);
    std::cin >> n;
	candies.resize(n);
	subset.reserve(n);
    for(int i = 0; i < n; ++i)
	    std::cin >> candies[i];

	std::sort(candies.begin(), candies.end());
	subsets(0, 0); 
	std::cout <<  (candies[0] != 1 ? 0 : result);
    return 0;
}