#include using namespace std; #define all(x) (x).begin(), (x).end() template void check_min(T &a, const T &b){ a = (a < b) ? a : b; } template void check_max(T &a, const T &b){ a = (a > b) ? a : b; } typedef long long ll; const int N = 300 + 3; const int MOD = 1e9 + 7; ll dp[N][2 * N * N], a[N], sum[N], n; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); freopen("duel.in", "r", stdin); freopen("duel.out", "w", stdout); cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i]; a[i] *= 2; } for(int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i]; fill(dp[n + 1], dp[n + 1] + 2 * N * N, 1); dp[n + 1][n * (n + 1) / 2] = 0; for(int pos = n; pos >= 1; --pos){ for(int points = 0; points <= n * (n + 1); ++points){ if(n * (n + 1) - points < points){ dp[pos][points] = 0; continue; } int other = sum[pos - 1] - points; if(n * (n + 1) - other < other){ dp[pos][points] = 0; continue; } dp[pos][points] = dp[pos + 1][points] + dp[pos + 1][points + a[pos]] + dp[pos + 1][points + a[pos] / 2]; while(dp[pos][points] >= MOD) dp[pos][points] -= MOD; //cout << dp[pos][points] << " - " << pos << " " << points << endl; } } cout << dp[1][0] << "\n"; }