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
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

#define f first
#define s second

const int MAXN = 5e3 + 13;
const long long MOD = 1e9 + 7;

int t[MAXN];
long long dp[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, x;
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
        cin >> t[i];
    sort(t + 1, t + n + 1);
    for (int i = 1; i <= n; i++) {
        x = t[i];
        for (int j = 5000; j > 5000 - x && j > x - 2; j--) {
            dp[5000] += dp[j];
            dp[5000] %= MOD;
        }
        for (int j = 5000; j > 0; j--) {
            if (j - x >= x - 1) {
                dp[j] += dp[j - x];
                dp[j] %= MOD;
            }
        }
    }
    long long ans = 0;
    for (int i = 1; i <= 5000; i++)
        ans += dp[i];
    cout << ans % MOD;
    return 0;
}