local mod = 998244353 local mfl = math.floor local function bmul(x, y) local x0, y0 = x % 31596, y % 31596 local x1, y1 = mfl(x / 31596), mfl(y / 31596) return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod end local function badd(x, y) return (x + y) % mod end local function badd(x, y) return (x + y) % mod end local n = io.read("*n") local a = {} for i = 1, n do a[i] = io.read("*n") end local pw = {1} for i = 2, n do pw[i] = badd(pw[i - 1], pw[i - 1]) end local z = 0 local ans = 0 for i = n - 1, 1, -1 do z = badd(z, pw[i]) ans = badd(ans, bmul(z, badd(a[i], mod - a[n + 1 - i]))) end print(ans)