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
#include <algorithm>
#include <cstdio>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REPD(i,n) FORD(i,0,n)
#define INT(x) int x; scanf("%d", &x)

const int mod = 1000000007;
int a[5000];
int r[5000];

int main() {
	INT(n);
	REP(i,n) scanf("%d", &a[i]);
	sort(a, a + n);
	int m = a[n - 1];
	r[0] = 1;
	REP(i,n) FORD(j,a[i]-1,m) {
		int t = min(j + a[i], m - 1);
		r[t] = (r[t] + r[j]) % mod;
	}
	int res = mod - 1;
	REP(i,m) res = (res + r[i]) % mod;
	printf("%d\n", res);
}