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<bits/stdc++.h>
using namespace std;
int t[5005],n;
long long ilosc[25000005];
vector<int> Sumy;
vector< pair<int,int> > newvec;
vector<int> Listasum;
map<int,int> M;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int mod = 1e9 + 7;

    cin >> n;
    for (int i = 1 ; i <= n ; i++)
        cin >> t[i];
    sort(t+1,t+n+1);
    int wieksze = 0;
    Sumy.push_back(0);
    ilosc[0] = 1;

    for (int i = 1 ; i <= n ; i++)
    {
        wieksze = (wieksze * 2) % mod;
        for (int j = 5005 ; j >= 0 ; j--)
        {
            if(t[i] <= j + 1)
            {
                if(j + t[i] > 5005)
                    wieksze = (wieksze + ilosc[j])%mod;
                else
                    ilosc[j+t[i]] = (ilosc[j+t[i]]+ ilosc[j]) % mod;
            }
        }
    }
    for (int i = 1 ; i <= 5005; i++)
    {
        wieksze = (wieksze + ilosc[i])%mod;
    }
    cout <<wieksze;
}