#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; const int MOD=998244353; ll modpow(ll x,ll n){ ll ans=1; while(n){ if(n&1) ans=ans*x%MOD; x=x*x%MOD; n/=2; } return ans; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n; cin>>n; vector A(n); rep(i,n) cin>>A[i]; ll sum=0; rep(i,n) sum+=A[i]; ll a=modpow(3,sum); if(sum%2==0) cout<<(a-1)*modpow(2,MOD-2)%MOD*modpow(a,MOD-2)%MOD<