#include using namespace std; int main() { int64_t n; cin >> n; vector a(n); for(int64_t i = 0; i < n; i++) cin >> a[i]; const int64_t mod = 998244353; vector b(n - 1); for(int64_t i = 0; i < n - 1; i++) b[i] = (a[i] - a[i + 1] + mod) % mod; vector pow2(n + 1); pow2[1] = 2; for(int64_t i = 2; i <= n; i++) { pow2[i] = pow2[i - 1] * 2; pow2[i] %= mod; } vector c(n - 1); for(int64_t i = 1; i <= n - 1; i++) { c[i - 1] = (pow2[i] - 1) * (pow2[n - i] - 1); c[i - 1] %= mod; } int64_t ans = 0; for(int64_t i = 0; i < n - 1; i++) { ans += b[i] * c[i]; ans %= mod; } cout << ans << endl; return 0; }