#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 998244353;

ll modpow(ll a, ll k) {
	if (k == 0) return 1;
	ll tmp = modpow(a, k / 2);
	if (k & 1)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

signed main() {
	int n; cin >> n;
	vector<ll> x(n+1);
	for (int i = 1; i < n+1; ++i)
		cin >> x[i];

	vector<ll> ans(n+1);
	ans[0] = 0;
	for (int i = 1; i <= n; ++i) {
		ans[i] = 2 * ans[i - 1] % mod;
		ll add = x[i] * (modpow(x[i] + 1, (ll)i - 1)) % mod;
		ans[i] += add;
		ans[i] %= mod;
	}

	cout << ans[n ] << endl;

	return 0;
}
