#!/usr/bin/python # -*- coding: utf-8 -*- # import from sys import stdin, setrecursionlimit setrecursionlimit(10**8) def int_map(): return map(int,input().split()) def int_list(): return list(map(int,input().split())) def int_mtx(N): x = [list(map(int, stdin.readline().split())) for _ in range(N)] return x def str_mtx(N): x = [list(stdin.readline()[:-1]) for _ in range(N)] return x def print_space(l): return print(" ".join([str(x) for x in l])) """ main code """ N = int(input()) a = int_list() MOD = 998244353 ans = 0 for i in range(N): ans += a[i]*pow(2,i,MOD)*(pow(2,N-(i+1),MOD)-1) ans %= MOD ans -= a[i]*(pow(2,i,MOD)-1)*pow(2,N-(i+1),MOD) ans %= MOD print(ans)