#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

#define debug(x) cout << #x << " is " << x << endl
#define inc(i, a, b) for (int i = a; i <= b; ++i)
typedef long long ll;
const int INF = 0x3f3f3f3f, N = 2005;
const int MOD = 1e9 + 7;

int n, m;

ll qpow(ll x, ll y) {
	ll ans = 1;
	for (; y; y >>= 1, x = x * x % MOD)
		if (y & 1) ans = ans * x % MOD;
	return ans;
}

int main() 
{
	scanf("%d%d", &n, &m);
	int a = n + m, b = n, x, y;
	for (int i = 1; i <= n; ++i) scanf("%d", &x), b += x;
	if (a < b) { puts("0"); return 0; }
	x = 1, y = 1;
	for (int i = 1; i <= b; ++i) {
		x = (ll)x * (a - i + 1) % MOD;
		y = (ll)y * i % MOD;
	}
	printf("%lld\n", (ll)x * qpow(y, MOD - 2) % MOD);
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
template<typename T,typename U>
ostream& operator<<(ostream& os, const pair<T,U>& p) { 
    cerr << ' ' <<  p.x << ',' << p.y; return os; }
template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
template <typename T> 
ostream& operator<<(ostream& os, const set<T>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
template<typename T,typename U>
ostream& operator<<(ostream& os, const map<T,U>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

const ll MOD = 998244353;

int main(void) {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n); F(n) cin >> a[i];
    sort(all(a));
    ll ret = 0; ll p = 0;
    F(n) {
        ret += a[i]*a[i];
        ret %= MOD;
        ret += (p*a[i])%MOD;
        ret %= MOD;
        p *= 2; p += a[i]; p %= MOD;
    }
    cout << ret << endl;
    return 0;
}
