#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 998244353;
int inv(int x) {
return x < 2 ? x : mod - (mod / x) * 1ll * inv(mod % x) % mod;
}
ll bp(ll a, ll p) {
ll r = 1;
while(p) {
if(p & 1) r = r * a % mod;
a = a*a%mod, p>>=1;
}
return r;
}
vector<ll> get_pent(int n) {
vector<ll> penta(n + 1);
penta[0] = 1;
penta[1] = -1;
for(ll x = 0; x <= n; x++) {
ll a = (3*x*x+7*x+4) / 2;
ll b = a + 2*x + 3;
// cout << a << " " << b << endl;
if(a > n && b > n) break;
if(a <= n) penta[a] = x % 2 ? 1 : -1;
if(b <= n) penta[b] = (x+1) % 2 ? 1 : -1;
}
return penta;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n, 1);
for(auto &i : a) cin >> i;
vector<ll> fact(2*n + 1, 1), ifact(2*n + 1, 1);
for(int i = 2; i <= 2*n; i++) {
ifact[i] = mod - (mod / i) * ifact[mod % i] % mod;
}
for(int i = 2; i <= 2*n; i++) {
fact[i] = fact[i-1] * 1ll * i % mod;
ifact[i] = ifact[i - 1] * 1ll * ifact[i] % mod;
}
auto C = [&](int n, int k) -> ll{
if(k < 0 || k > n) return 0;
ll res = fact[n] * ifact[k] % mod;
return res * ifact[n - k] % mod;
};
vector<ll> G(n+1), SC(n+1), BC(n+1);
vector manySC(n+1, vector<ll>(n+1));
manySC[0][0] = 1;
auto manyBC = manySC;
for(int i = 1; i <= n; i++) {
G[i] = bp(2, i*(i-1)/2);
SC[i] = G[i];
for(int j = 1; j < i; j++) {
ll tmp = G[i - j] * SC[j] % mod;
tmp = tmp * C(i - 1, j -1) % mod;
SC[i] = (SC[i] + mod - tmp) % mod;
}
ll base = SC[i] * i % mod;
auto tmpSC = manySC;
for(int sum = 0; sum <= n; sum++) {
ll x = 1;
for(int add = 1; sum + add * i <= n; add++) {
x = x * base % mod;
x = x * C(sum + add * i, i) % mod;
ll y = x * ifact[add] % mod;
for(int count = 0; count + add <= n; count++) {
ll v = y * manySC[sum][count];
// if(sum + add * i == 2 && count + add == 1 && v) cout <<"::"<< sum << " " << count << " " << add << " " << i << " " << v << endl;
tmpSC[sum + add * i][count + add] = (tmpSC[sum + add * i][count + add] + v)%mod;
}
}
}
manySC = tmpSC;
BC[i] = SC[i];
for(int j = 1; j < i; j++) {
ll pw = 1;
for(int split = 1; split <= i-j; split++) {
pw = pw * j % mod;
ll tmp = manySC[i - j][split] * BC[j] % mod;
tmp = tmp * C(i - 1, j - 1) % mod;
tmp = tmp * pw % mod;
// cout << i << " - " << j << " " << split << " " << tmp << endl;
BC[i] = (BC[i] + mod - tmp) % mod;
}
}
// cout << i << " " << G[i] << " " << SC[i] << " " << BC[i] << endl;
// cout << "_" << manySC[2][1] << " " << manySC[2][2] << endl;
base = BC[i] * i % mod;
auto tmpBC = manyBC;
for(int sum = 0; sum <= n; sum++) {
for(int count = 0; count <= n; count++) {
ll x = 1;
for(int add = 1; count + add <= n && sum + add * i <= n; add++) {
x = x * C(sum + add * i - (count + add), i - 1) % mod;
x = x * base % mod;
// ll y = x * (add > 1 ? ifact[add] : 1) % mod;
ll y = x * C(count + add, add) % mod;
ll v = y * manyBC[sum][count];
// if(sum + add * i == 4 && count + add == 2 && v) cout <<"::"<< sum << " " << count << " " << add << " " << i << " " << v << endl;
tmpBC[sum + add * i][count + add] = (tmpBC[sum + add * i][count + add] + v)%mod;
}
}
}
manyBC = tmpBC;
}
// for(int sum = 0; sum <= n; sum++) {
// for(int count = 0; count <= n; count++) {
// cout << sum << " " << count << " " << manyBC[sum][count] << endl;
// }
// }
vector<ll> prod(n+1, 0); prod[0] = 1;
for(int i = 0; i < n; i++) {
for(int j = n+1; j-- > 1;)
(prod[j] += prod[j - 1] * a[i]) %= mod;
// cout << prod[0] << " " << prod[1] << endl;
}
ll ans =0, sum = 0;
for(int c = 1; c <= n; c++) {
ll trees = manyBC[n][c];
trees = trees * bp(n, c - 1) % mod;
trees = trees * bp(n, mod - 2) % mod;
(ans += trees * prod[c]) %= mod;
(sum += trees) %= mod;
// cout << c << " == " << trees << " " << prod[c] << endl;
}
// cout << ans << " " << sum << " " << SC[n] << '\n';
cout << ans << '\n';
}