#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _WIN64 # include #endif #ifdef _MSC_VER # include # define __builtin_popcount __popcnt # define __builtin_popcountl __popcnt64 #endif using namespace std; #define ll long long #define rep(i, init, n) for(ll i = init; i < (ll)n; i++) #define rrep(i, init, n) for(ll i = init; i >= (ll)n; i--) #define all(x) (x).begin(), (x).end() #define sz(x) (ll)(x.size()) #define Out(x) cout << x << endl #define Yes cout << "Yes" << endl #define No cout << "No" << endl #define Ans cout << ans << endl #define PI 3.14159265358979 #define MOD 998244353 const int inf32 = INT_MAX / 2; const ll inf64 = 1LL << 60; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } templatebool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } // ------------------------------------------------------------------------------------------------- struct mint { ll x; mint(ll val = 0) { x = (val % MOD + MOD) % MOD; } mint operator-() const { return mint(-x); } mint& operator+=(const mint& other) { x += other.x; if (x >= MOD) x -= MOD; return *this; } mint& operator-=(const mint& other) { x -= other.x; if (x < 0) x += MOD; return *this; } mint& operator*=(const mint& other) { (x *= other.x) %= MOD; return *this; } mint& operator/=(const mint& other) { *this *= other.pow(MOD - 2); return *this; } mint operator+(const mint& other) const { return mint(*this) += other; } mint operator-(const mint& other) const { return mint(*this) -= other; } mint operator*(const mint& other) const { return mint(*this) *= other; } mint operator/(const mint& other) const { return mint(*this) /= other; } mint pow(ll i) const { mint ret = 1; for (mint tmp = x; i; tmp *= tmp, i >>= 1) if (i & 1) ret *= tmp; return ret; } friend ostream& operator<<(ostream& os, const mint& m) { os << m.x; return os; } }; int main() { int n; cin >> n; vector a(n + 1); rep(i, 1, n + 1) cin >> a[i]; vector dp(n + 1, vector(20000 + 1)); dp[0][10000] = 1; rep(i, 1, n + 1)rep(j, 0, 20000 + 1) { if (j + a[i] <= 20000) dp[i][j + a[i]] += dp[i - 1][j]; if (j - a[i] >= 0) dp[i][j - a[i]] += dp[i - 1][j]; } mint ans = 0; rep(i, 0, 20000 + 1) ans += (mint)abs(i - 10000) * dp[n][i]; Ans; return 0; }