#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,m;
int sa;
int ans1,ans2;
int ksm(ll ta,int tp){
    int s=1;
    for(;tp;ta=ta*ta%mod,tp>>=1) if(tp&1) s=ta*s%mod;
    return s;
}
int main(){
    scanf("%d %d",&n,&m);
    m+=n;
    for(int i=1,a;i<=n;i++){
        scanf("%d",&a); sa+=a;
    }
    sa+=n;
    ans1=ans2=1;
    if(m<sa){
        printf("0\n");
        return 0;
    }
    for(int i=1;i<=sa;i++) ans1=1ll*ans1*i%mod;
    for(int i=1;i<=sa;i++) ans2=1ll*ans2*(m-i+1)%mod;
    printf("%lld\n",1ll*ans2*ksm(ans1,mod-2)%mod);
    return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;

int  gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll N;
    cin >>N;
    vl A(N);
    ll ans=0;
    rep(i,N){
        cin >>A[i];
    }
    sort(all(A));
    ll pas=0;
    rep(i,N){
        ans = ans + ( (A[i]*A[i])%998244353+ (A[i]*pas)%998244353)%998244353;
        ans %=998244353;
        pas = (pas*2+A[i])%998244353;
    }
    cout<<ans<<endl;
}
