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

#define mp make_pair
#define fi first
#define se second

using namespace std;

const int mod = 1e9 + 7;
const int N = 5000;
long long dp[N];
int t[N], n;
long long sum;

void add(int i, long long val) {
  if (val != 0) {
    i = min(i, N - 1);
    dp[i] += val;
    dp[i] %= mod;
    sum += val;
    sum %= mod;
  }
}

int main() {
  ios_base::sync_with_stdio(0);

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }

  sort(t, t + n);

  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = N - 1; j >= t[i] - 1; j--) {
      add(j + t[i], dp[j]);
    }
  }
  cout << sum << endl;

  return 0;
}