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

using namespace std;

const int MOD = 1e9 + 7;

int main(){
    int n; cin>>n;
    vector<int> dp(5000*n, 0);
    dp[0] = 1;
    vector<int> v(n);
    for(int i = 0; i < n; i++)cin>>v[i];
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++){
        int a = v[i];
        for(int j = dp.size() - a - 1; j>= a-1; j--){
            dp[j+a] = (dp[j+a] + dp[j])%MOD;
        }
    }
    int result = 0;
    for(int i = 1; i < dp.size(); i++){
        result = (result + dp[i])%MOD;
    }
    cout<<result;
}