#include #include using namespace std; using mint = atcoder::modint998244353; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector p2(n); p2[0] = 1; for (int i = 1; i < n; i++) { p2[i] = p2[i - 1] * 2; } mint ans = 0; for (int i = 0; i < n; i++) { ans -= a[i] * (p2[i] - p2[n - i - 1]); } cout << ans.val() << endl; }