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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
#define boost                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long
#define int long long
#define st first
#define nd second

using namespace std;

const int mod(1e9 + 7);
const int N(5e3 + 13);

int n, q, val, res, maxval = 0;
map<int, int> M;
int t[N];

int quickMod(int value) { return value < mod ? value : value - mod; }

int mapSum() {
  int sum = 0;
  for (auto it : M) {
    sum = quickMod(sum + it.nd);
  }
  return sum;
}

void countWays() {
  int index;
  M[0] = 1;

  for (int i = 1; i <= n; i++) {
    val = t[i];
    for (auto it = M.rbegin(); it != M.rend(); it++) {
      if (it->st < t[i] - 1) {
        break;
      }
      index = min(it->st + val, maxval);
      M[index] = quickMod(M[index] + it->nd);
    }
  }
}

void read() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    maxval = max(maxval, t[i]);
  }
}

int32_t main() {
  boost;
  read();
  sort(t + 1, t + n + 1);
  countWays();
  cout << mapSum() - 1 << endl;
}