n=gets.to_i M=998244353 i=0 p gets.split.sum{2.pow(n-2,M)*_1.to_i*-~i+=1}%M