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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* -----------------------
Autor: Tomasz Boguslawski
-------------------------- */
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<sstream>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include <fstream>
#include<math.h>

#define FOR(x, b, e) for(long x = b; x <= (e); x++)
#define FORD(x, b, e) for(long x = b; x >= (e); x--)
#define VAR(v, n) __typeof(n) v = (n)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define DEBUG if (debug)
#define MIN(a,b) ((a>b)?b:a)
#define MAX(a,b) ((a>b)?a:b)
#define LL long long

using namespace std;

long n;
vector<long> cuks;

LL w2[11001];

LL sumuj(long a, long b)
{
    LL suma=0;
    FOR(i,a,b) suma=(suma+w2[i])%1000000007;
    return suma;
}

LL oblicz2()
{
    FOR(i,0,11000) w2[i]=0; long maksCuks=cuks[cuks.size()-1]; long granica=2*maksCuks;
    //cout << "Granica= " << granica << "\n";
    w2[0]=1; LL c; LL reszta=0;
    LL maks=0; long low, up;
    FOR(i,1,n)
    {
        c=cuks[i-1]; // dodajemy cuksa "c":
        //cout << "Dodaje cuksa: " << c << "\n";
        low=2*c-1;
        up=maks+c;
        //cout << " low=" << low << " up=" << up << "\n";
        if (up<low) break; // nic nie daje ta paczka cuksow i zadna nastepna
        reszta=((reszta*2)+sumuj(granica-c+1, granica))%1000000007;
        FORD(j,MIN(up,granica),low) w2[j]=(w2[j]+w2[j-c])%1000000007;
        maks=up;
        //FOR(j,0,MIN(maks,granica)) cout << " " << j << ": " << w2[j] << "\n";
        //FOR(j,0,granica) cout << " " << j << ": " << w2[j] << "\n";
        //cout << " reszta=" << reszta << "\n";
    }
    LL suma=0;
    FOR(i,1,granica) suma=(suma+w2[i])%1000000007;
    suma=(suma+reszta)%1000000007;
    return suma;
}


/// MAIN
int main(int argc, char* argv[])
{
    // magic formula, which makes streams work faster:
	ios_base::sync_with_stdio(0);

	cin >> n; long c;
	FOR(i,1,n)
	{
	    cin >> c;
	    cuks.push_back(c);
	}

    sort(cuks.begin(), cuks.end());

    cout << oblicz2() << "\n";

    return 0;
};