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
#include <bits/stdc++.h>
using namespace std;

const int MOD=1000000007;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> A(n);
    for (int &a:A) cin >> a;
    sort(A.begin(), A.end());

    vector<int> V(5000+1);
    V[0]=1;
    for (int a:A) {
        for(int i=5000; i>5000-a && i>=a-1; i--)
            (V[5000]+=V[i])%=MOD;
            
        for(int i=5000-a; i>=a-1; i--)
            (V[i+a]+=V[i])%=MOD;
    }
    cout << accumulate(V.begin(), V.end(), -1, [](int a, int b) {return (a+b)%MOD;}) << endl;
    return 0;
}