#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll MOD = 998244353; int main() { int N; cin >> N; vector A(N); ll sum = 0; for (int i = 0; i < N; ++i) { cin >> A[i]; sum += A[i]; } ll dp[N + 1][2 * sum + 1]; memset(dp, 0, sizeof(dp)); dp[0][sum] = 1; for (int i = 0; i < N; ++i) { ll a = A[i]; for (int v = 0; v <= 2 * sum; ++v) { if (dp[i][v] == 0) continue; dp[i + 1][v - a] += dp[i][v]; dp[i + 1][v + a] += dp[i][v]; dp[i + 1][v - a] %= MOD; dp[i + 1][v + a] %= MOD; } } ll ans = 0; for (int v = 0; v <= 2 * sum; ++v) { ans += dp[N][v] * abs(v - sum); ans %= MOD; } cout << ans << endl; return 0; }