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
/*
 * author: pavveu
 * task: Potyczki Algorytmiczne 2020 Runda 5 - Cukierki [C]
*/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define FOR(iter, val) for(int iter = 0; iter < (val); iter++)
#define all(x) begin(x), end(x)

template<typename T>
void initialize_matrix(vector<vector<T>>& matrix, int rows, int cols, T val) {
	assert(matrix.empty());
	FOR(row, rows) 
		matrix.emplace_back(cols, val);
}

void go() {
	int n; cin >> n;
	vi a(n); for (auto& i : a) cin >> i;
	sort(all(a));

	size_t all_sum { accumulate(all(a), size_t(0)) };

	vll dp(all_sum + 1, 0);
	dp[0] = 1;

	const ll mod = 1e9 + 7;

	int sum { 0 };
	for (int x : a) {
		sum += x;
		for (int i = sum - x; i >= x - 1; i-- ) 
			dp[i + x] = (dp[i + x] + dp[i]) % mod;

	}

	ll ans { -1ll };
	for (ll x : dp) ans = (ans + x) % mod;

	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	go();

	return 0;
}