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
52
53
54
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>

constexpr int A_MAX = 5000;
constexpr long long int MOD = 1000 * 1000 * 1000 + 7;



int main() {
    std::ios::sync_with_stdio(false);

    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(auto& val : a)
        std::cin >> val;
    
    std::sort(a.begin(), a.end());


    std::vector<long long int> subsets(A_MAX + 1, 0);
    long long int large_x_subsets = 0;


    subsets[0] = 1;
    for(auto val : a) {
        large_x_subsets += large_x_subsets;
        large_x_subsets %= MOD;
        for(int i = A_MAX; i >= 0; i--) {
            if(i+1 < val)
                continue;
            
            if(i + val > A_MAX) {
                large_x_subsets += subsets[i];
                large_x_subsets %= MOD;
            } else {
                subsets[i+val] += subsets[i];
                subsets[i+val] %= MOD;
            }
        }
    }

    long long int sum = large_x_subsets;
    for(long long int i = 1; i <= A_MAX; i++) {
        sum += subsets[i];
        sum %= MOD;
    }
    std::cout << sum << std::endl;

    return 0;
}