import std; void main () { int N = readln.chomp.to!int; int[] A = readln.split.to!(int[]); solve(N, A); } void solve (int N, int[] A) { const int MOD = 998244353; long ans = 0; foreach (i, a; A) { long x = cast(int) i + 1; long term1 = modPow(2, x-1, MOD); long term2 = 0; if (2 <= x) term2 = (x-1) * modPow(2, x-2, MOD) % MOD; long sum = (term1+term2) % MOD; if (x < N) { sum *= modPow(2, N-x-1, MOD); sum %= MOD; ans += a*sum % MOD; } else { ans += a*sum % MOD; } // dbg //writeln("x: ", x, " val: ", a*(term1+term2)); ans %= MOD; } writeln(ans); } void read(T...)(string S, ref T args) { auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } } long modPow (long a, long x, const int MOD) { // assertion assert(0 <= x, format("x = %d", x)); assert(1 <= MOD); // normalize a %= MOD; a += MOD; a %= MOD; // simple case if (MOD == 1) { return 0L; } if (x == 0) { return 1L; } if (x == 1) { return a; } // calculate long res = 1L; long base = a % MOD; while (x != 0) { if ((x&1) != 0) { res *= base; res %= MOD; } base = base*base; base %= MOD; x >>= 1; } return res; }