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

using namespace std;

const int P = 1000000007;
const int M = 5005;

int main() {
  int n; scanf("%d", &n);
  vector<int> a(n);
  for (int i=0; i<n; ++i) scanf("%d", &a[i]);
  sort(a.begin(), a.end());

  vector<int> t(M+1, 0);
  t[0] = 1;
  for (int i=0; i<n; ++i) {
    for (int j=M; j>=a[i]-1; --j) {
      int k = min(j + a[i], M);
      t[k] = (t[k] + t[j]) % P;
    }
  }

  int result = 0;
  for (int i=1; i<=M; ++i) {
    result = (result + t[i]) % P;
  }
  printf("%d\n", result);
  return 0;
}