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
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define fi first
#define se second
#define pii pair <int,int>
#define pli pair <ll,int>
#define pll pair <ll,ll>
#define ppi pair <pii,pii>
#define vi vector <int>
#define vl vector <ll>
#define uset unordered_set
#define umap unordered_map
#define INF (1<<30)
#define INF_LL (1ll<<60)
#define MAX 2000005
#define MAX_LVL 21


#pragma GCC optimize("unroll-loops,fast-math")
//#pragma GCC optimize("Ofast")	// O3 + more, be aware with floats as it may change order of computation
//#pragma GCC optimize("O3")		
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")

using namespace std;


template <typename T>
ostream & operator << (ostream &out, const vector <T> &V);

template <typename T>
ostream & operator << (ostream &out, const set <T> &S);

template <typename T>
ostream & operator << (ostream &out, const multiset <T> &S);

template <typename T1, typename T2>
ostream & operator << (ostream &out, const pair <T1, T2> &P);

template <typename T1, typename T2>
ostream & operator << (ostream &out, const map <T1, T2> &M);


void testcase() {
	int n;
	cin >> n;
	int* A = (int*) malloc(n * sizeof(int));
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(A, A+n);
	const int q = 1000000007, MAX_V = 5000;
	ll* D = (ll*) calloc(MAX_V+1, sizeof(ll));
	D[0] = 1;
	for (int i = 0; i < n; i++) {
		int a = A[i];
		for (int b = MAX_V; b >= a-1; b--) {
			int c = min(b+a, MAX_V);
			D[c] += D[b];
			if (D[c] >= q) {
				D[c] %= q;
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= MAX_V; i++) {
		ans += D[i];
	}
	cout << ans % q <<endl;
}

void init() {
    
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    init();
    int T = 1;
    //cin >> T;
    for (int t = 1; t <= T; t++) {
        testcase();
    }
    return 0;
}




template <typename T>
ostream & operator << (ostream &out, const vector <T> &V) {
	if (!V.empty()) {
		out << "{";
		for (auto v : V)
			out << v << ", ";
		out << "\b\b}";			// \b is backspace
	}
	else {
		out << "{}";
	}
	return out;
}

template <typename T>
ostream & operator << (ostream &out, const set <T> &S) {
	if (!S.empty()) {
		out << "set{";
		for (auto v : S)
			out << v << ", ";
		out << "\b\b}";			// \b is backspace
	}
	else {
		out << "{}";
	}
	return out;
}

template <typename T>
ostream & operator << (ostream &out, const multiset <T> &S) {
	if (!S.empty()) {
		out << "set{";
		for (auto v : S)
			out << v << ", ";
		out << "\b\b}";			// \b is backspace
	}
	else {
		out << "{}";
	}
	return out;
}

template <typename T1, typename T2>
ostream & operator << (ostream &out, const map <T1,T2> &M) {
	if (!M.empty()) {
		out << "map{";
		for (auto &kv : M)
			out << "(" << kv.fi << ": " << kv.se << ")" << ", ";
		out << "\b\b}";			// \b is backspace
	}
	else {
		out << "{}";
	}
	return out;
}

template <typename T1, typename T2>
ostream & operator << (ostream &out, const pair <T1, T2> &P) {
	out << "{" << P.first << ", " << P.second << "}";
	return out;
}