import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a = new long[n]; long mod = 998244353; for(int i = 0; i < n; i++){ a[i] = sc.nextLong(); } long ans = 0; for(int i = 0; i < n; i++){ long cntL = rep2(2,i,mod); long cntR = rep2(2,n-1-i,mod); cntL = (cntL+mod-1) % mod; cntR = (cntR+mod-1) % mod; ans += (a[i]*cntR) % mod; ans %= mod; ans -= (a[i]*cntL) % mod; if(ans < 0) ans += mod; } System.out.println(ans); } private static long rep2(long b, long n, long mod){ if(n == 0) return 1; long bn = rep2(b,n/2,mod); if(n % 2 == 0){ return (bn*bn)%mod; }else{ return (bn*bn)%mod*b%mod; } } }