/* -*- coding: utf-8 -*- * * 1645.cc: No.1645 AB's abs - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100; const int MAX_A = 100; const int MAX_S = MAX_N * MAX_A; const int MOD = 998244353; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N], dp[MAX_N + 1][MAX_S * 2 + 1]; /* subroutines */ inline void addmod(int &a, int b) { a = (a + b) % MOD; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); dp[0][MAX_S] = 1; int minj = MAX_S, maxj = MAX_S; for (int i = 0; i < n; i++) { for (int j = minj; j <= maxj; j++) { addmod(dp[i + 1][j + as[i]], dp[i][j]); addmod(dp[i + 1][j - as[i]], dp[i][j]); } minj -= as[i], maxj += as[i]; } int sum = 0; for (int j = MAX_S; j <= maxj; j++) addmod(sum, (ll)(j - MAX_S) * dp[n][j] % MOD); printf("%d\n", (sum * 2) % MOD); return 0; }