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;

long long table[5005];
vector < long long > numbers;
long long p=1000000007;
long long len=5001;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int in;
        cin >> in;
        numbers.push_back(in);
    }
    sort(numbers.begin(),numbers.end());

    //if(numbers[0]==1)table[2]=1;
    for(int i=0;i<n;i++){
        for(int j=len;j>=numbers[i];j--){
            if(table[j]!=0){
                //cout << "dknv " << i << " " << j << endl;
                if(numbers[i]+j<=len){
                    table[numbers[i]+j]=(table[numbers[i]+j]+table[j])%p;
                }
                else table[len]=(table[len]+table[j])%p;
            }
        }
        if(numbers[i]==1)table[2]=(table[2]+1)%p;
    }
    long long result=0;
    for(int i=1;i<=len;i++){
        result=(result+table[i])%p;
    }
    cout << result << "\n";



    return 0;
}