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

using namespace std;
typedef long long int lli;
lli total = 0;
lli mod = 1e9+7;

void powerset(int curr, vector<lli>& v, lli sum) {
    if (curr == v.size()) {
        total++;
        return;
    }
    if (v[curr] <= sum + 1) {
        powerset(curr+1, v, sum);
        powerset(curr+1, v, sum + v[curr]);
    } else {
        total++;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    lli n;
    cin >> n;
    vector<lli> v(n);
    for (int i = 0; i < n; i++) {
        int val;
        cin >> val;
        v[i] = val;
    }
    sort(v.begin(), v.end());
    powerset(0, v, 0);
    cout << (total-1) % mod << '\n';
    return 0;
}