#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int x[1000005];
unsigned long long diff[1000005], pw[1000005];
const int Mod = 998244353;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  diff[1] = x[1];
  pw[0] = 1;
  for (int i = 1; i <= n; i++) {
    pw[i] = pw[i - 1] * 2ll;
    pw[i] %= Mod;
  }
  diff[1] *= pw[n - 1];
  diff[1] %= Mod;
  unsigned long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += diff[i];
    ans %= Mod;
    diff[i + 1] = diff[i] - x[i] * pw[n - i - 1] + x[i + 1] * pw[n - i - 1];
    diff[i + 1] %= Mod;
    while (diff[i + 1] < 0) {
      diff[i + 1] += Mod;
    }
  }
  ans += diff[n];
  ans %= Mod;
  cout << ans;
  return 0;
}
