#include <bits/stdc++.h>
using namespace std;
template <typename T>
T qabs(T x) {
  return x < 0 ? -x : x;
}
template <typename T>
T qmin(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T qmax(T a, T b) {
  return a < b ? b : a;
}
const int maxn = 1e6;
int a[maxn];
const long long mod = 998244353;
long long b[maxn];
long long Pow[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  Pow[0] = 1;
  for (int i = 1; i < n; ++i) Pow[i] = 2 * Pow[i - 1] % mod;
  b[0] = a[0] * Pow[n - 1];
  for (int i = 1; i < n; ++i)
    b[i] = ((b[i - 1] - a[i - 1] * Pow[n - i - 1] % mod +
             a[i] * Pow[n - i - 1] % mod) %
                mod +
            mod) %
           mod;
  long long sum = 0;
  for (int i = 0; i < n; ++i) sum = (sum + b[i]) % mod;
  cout << sum;
  return 0;
}
