#include <bits/stdc++.h>

typedef long long ll;

const int N = 100;
const int S = N * N;
const int P = 998244353;

inline int norm(int x) {if (x >= P) x -= P; return x;}
inline int reduce(int x) {if (x < 0) x += P; return x;}
inline void add(int &x, int y) {if ((x += y) >= P) x -= P;}
inline void sub(int &x, int y) {if ((x -= y) < 0) x += P;}
int mpow(int b, int p) {
	int r = 1;
	for (; p; p >>= 1, b = (ll)b * b % P)
		if (p & 1) r = (ll)r * b % P;
	return r;
}

int fct[N + 5];
int f[N + 5][N + 5][2*S + 5], w[N + 5], n;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &w[i]);
	
	fct[0] = 1; for (int i = 1; i <= n; i++) fct[i] = (ll)fct[i - 1] * i % P;

	f[0][0][S] = 1;
	for (int i = 0; i < n; i++) for (int j = 0; i + j < n; j++) {
		int p = w[i + j + 1];
		for (int k = p; k <= (S << 1); k++) add(f[i + 1][j][k], f[i][j][k - p]);
		for (int k = (S << 1) - p; k >= 0; k--) add(f[i][j + 1][k], f[i][j][k + p]);
	}
	
	int ans = 0;
	for (int i = 0; i <= n; i++) ans = (ans + (ll)fct[i] * fct[n - i] % P * f[i][n - i][S]) % P;
	printf("%d\n", ans);
}
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

#define MOD 998244353



long long pow_mod(long long x, long long y) {
	int res = 1;
	while (y) {
		if (y & 1)res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}

long long inv_mod(long long a) {
	return pow_mod(a,MOD-2);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);


	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];


	map<int, int> mp;
	rep(i, n) {
		mp[a[i]]++;
	}

	int cnt = 0;
	long long sum = 0;
	for (auto p : mp) {
		long long c = p.first * pow_mod(2, cnt) % MOD * (pow_mod(2, p.second) - 1) % MOD;
		sum += c;
		cnt += p.second;
	}
	sum %= MOD;
	long long ans = 0;

	long long inv2 = inv_mod(2);
	for (auto p : mp) {
		sum -= p.first * (pow_mod(2, p.second) - 1) % MOD;
		sum *= pow_mod(inv2, p.second);
		sum = (sum % MOD + MOD) % MOD;

		ans += p.first * (pow_mod(2, p.second) - 1) %MOD * sum % MOD;
	}
	for (auto p : mp) ans += (long long)p.first * p.first % MOD * (pow_mod(2, p.second) - 1) % MOD;
	ans = (ans % MOD + MOD) % MOD;

	cout << ans << endl;

	return 0;
}
