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
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000000000000007
using ll = long long;

int n, a[5007], dp[5007], mod = 1000000007, wynik;

int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for (int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    dp[0] = 1;
    for (int i=0; i<n; i++)
    {
        for (int j=5000; j>=a[i]-1; j--)
        {
            int poz = min(5000, j+a[i]);
            dp[poz] += dp[j];
            dp[poz] %= mod;
        }
    }
    for (int i=1; i<=5000; i++)
    {
        wynik += dp[i];
        wynik %= mod;
    }
    cout << wynik << "\n";

    return 0;
}