#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int INF = 1e18;
const int MAXN = 1e6 + 5;
const int T = 2500 + 3;
long long pow2[MAXN], dif[MAXN], p;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout.precision(10);
  setlocale(LC_ALL, "Russian");
  int i = 0, n, j, m, q;
  cin >> n;
  vector<int> a(n + 1);
  for (i = 1; i <= n; i++) cin >> a[i];
  pow2[0] = 1;
  for (i = 1; i <= n; i++) {
    pow2[i] = 2ll * pow2[i - 1] % MOD;
  }
  for (i = 0; i < n; i++) {
    dif[i + 1] = dif[i] + (pow2[n - 1 - i] * (a[i + 1] - a[i])) % MOD;
    dif[i + 1] = dif[i + 1] % MOD;
    p = (p + dif[i + 1]) % MOD;
  }
  cout << p;
  return 0;
}
