#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
long long mat;
int main() {
  ios::sync_with_stdio(0);
  long long n;
  cin >> n;
  a.resize(n);
  for (long long(i) = (0); (i) < (long long)n; (i)++) cin >> a[i];
  long long mat = a[0];
  vector<long long> m(1, a[0]);
  for (long long(i) = (1); (i) < (long long)n; (i)++) {
    m.push_back((m.back() * 2 + a[i] - a[i - 1]) % 998244353);
    mat = (mat * 2 + m.back()) % 998244353;
  }
  cout << mat % 998244353;
  return 0;
}
