#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define lowbit(x) (x&-x)
#define reg register
#define mkpr make_pair
#define fir first
#define sec second
typedef long long LL;
typedef unsigned long long uLL;
const int INF=0x3f3f3f3f;
const int mo=998244353;
const LL jzm=2333;
const int iv2=499122177;
const double Pi=acos(-1.0);
typedef pair<int,int> pii;
const double PI=acos(-1.0);
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=getchar();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=getchar();}
	while('0'<=s&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=getchar();}
	x*=f;
}
template<typename _T>
void print(_T x){if(x<0){x=(~x)+1;putchar('-');}if(x>9)print(x/10);putchar(x%10+'0');}
int n,a[MAXN],pow2[MAXN],inv2[MAXN],suf[MAXN],ans;
int add(int x,int y){return x+y<mo?x+y:x+y-mo;}
signed main(){
	read(n);for(int i=1;i<=n;i++)read(a[i]);sort(a+1,a+n+1);
	pow2[0]=1;for(int i=1;i<=n;i++)pow2[i]=add(pow2[i-1],pow2[i-1]);
	inv2[0]=1;for(int i=1;i<=n;i++)inv2[i]=1ll*inv2[i-1]*iv2%mo;
	for(int i=n;i>0;i--)suf[i]=add(suf[i+1],1ll*a[i]*pow2[i-1]%mo);
	for(int i=1;i<=n;i++)ans=add(ans,1ll*suf[i+1]*inv2[i]%mo*a[i]%mo);
	for(int i=1;i<=n;i++)ans=add(ans,1ll*a[i]*a[i]%mo);printf("%d\n",ans);
	return 0;
}
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define PI 3.141592653589793
//#include <atcoder/all>
//using namespace atcoder;
//using Mint = modint;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n, ll p){
	if(n==0) return 1;
	if(n%2) return (a*modpow(a, n-1, p))%p;
	if(!(n%2)){
		ll t=modpow(a, n/2, p);
		return (t*t)%p;
	}
}

int main(){
  int n, m; cin >> n >> m; ll igai = 0; ll iga = 0, ig = 0;
  if(n==1){
    cout << m << endl; return 0;
  }
  ll dp[m+1][n+1] = {};
  rep(i, m+1){
    rep(j, n+1){
      if(j==0) dp[i][j] = 1;
      else dp[i][j] = dp[i][j-1]*i%mod;
    }
  }
  ll minv[m+1];
  rep(i, m+1){
    minv[i] = modinv(i, mod);
  }
  for(int i=1; i<=n-1; i++){
    for(int j=1; j<=m; j++){
      ll now = dp[m][n-1] - dp[m][i-1]*dp[m-j][n-i]%mod;
      if(now<0) now+=mod;
      now%=mod;
      now*=minv[j];
      iga+=now; iga%=mod;
    }
  }
  //cout << (modpow(m, n, mod)*n%mod-igai+mod)%mod << endl;
  ll all = modpow(m, n, mod)*n%mod;
  all-=iga;
  if(all<0) all+=mod; all%=mod;
  cout << all << endl;
}
      