#include #include using namespace std; using LL = long long; using P = pair; using Graph = vector>; const int INF = 1 << 29; const long long LINF = 1LL << 60; #define all(x) (x).begin(), (x).end() #define rep(i,n) for(int i = 0; i < (n); ++i) templatevoid chmin(T&a, T b){if(a > b) a = b;} templatevoid chmax(T&a, T b){if(a < b) a = b;} const long long M = 998244353; int main(){ int N; cin >> N; vector A(N); for(int i = 0; i < N; ++i) cin >> A[i]; vector> dp(N, vector(20001, 0)); dp[0][A[0]+10000] = 1; dp[0][10000-A[0]] = 1; for(int i = 1; i < N; ++i){ for(int j = 0; j < 20001; ++j){ if(dp[i-1][j]){ dp[i][j+A[i]] += dp[i-1][j]; dp[i][j-A[i]] += dp[i-1][j]; } } } long long ans = 0; for(int i = 0; i < 20001; ++i){ if(dp[N-1][i]){ ans += dp[N-1][i]*abs(i - 10000); ans %= M; } } cout << ans << endl; }