#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ri register int
#define ll long long
#define ui unsigned int
il ll read(){
    bool f=true;ll x=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=false;ch=getchar();}
    while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    if(f) return x;
    return ~(--x);
}
il int read(char *s){
    int len=0;
    register char ch=getchar();
    while(ch==' '||ch=='\n') ch=getchar();
    while(ch!=' '&&ch!='\n'&&ch!=EOF) s[++len]=ch,ch=getchar();
    return len;
}
il void write(const ll &x){if(x>9) write(x/10);putchar(x%10+'0');}
il void print(const ll &x) {x<0?putchar('-'),write(~(x-1)):write(x);putchar('\n');}
il ll max(const ll &a,const ll &b){return a>b?a:b;}
il ll min(const ll &a,const ll &b){return a<b?a:b;}
const ll mod=998244353;
int n;
const int MAXN=2e5+7;
ll a[MAXN],ans,sum;
int main(){
    n=read();
    for(ri i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+n+1);
    for(ri i=1;i<=n;++i){
        ans=(ans+a[i]*sum)%mod;
        ans=(ans+a[i]*a[i])%mod;
        sum=(sum*2+a[i])%mod;
    }
    print(ans);
    return 0;
}
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // int64_t
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define REP(i,m,n) for(int i = m; i <= (n); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

const int INF = 1e9+7;   //10oku7



ll mod_pow(ll x , ll y , ll m){
  if (y == 0) return 1;
  if (y == 1) return x % m;
  ll rep = mod_pow(x, y/2, m) * mod_pow(x, y/2, m);
  if (y % 2 == 1 ) rep *= (x % m);
  rep %= m;
  return rep;
}

ll circ(ll x , ll y){
  ll res = mod_pow(x , y ,4);
  if (res == 0 ) res = 4;
  return res;
}

int main() {

  ll A,B,C;
  cin >> A >> B >> C;
  A %= 10;
  ll ans = mod_pow( A , circ(B,C) ,10);

//  cout << circ (B,C) << endl;
//  cout << mod_pow(A,B, 10) << endl;
  cout << ans << endl;

}
