#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 403, mod = 998244353;
template<typename T>
void read(T &x){
	int ch = getchar(); x = 0; bool f = false;
	for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-';
	for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
void qmo(int &x){x += (x >> 31) & mod;}
int ksm(int a, int b){
	int res = 1;
	for(;b;b >>= 1, a = (LL) a * a % mod) if(b & 1) res = (LL) res * a % mod;
	return res;
}
template<typename T>
inline bool chmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
int n, h[N], pw2[N], ans, f[N][N], g[N][N];
int solve(int l, int r, int val){
	if(l > r) return 0;
	int mid = l;
	for(Rint i = l + 1;i <= r;++ i) if(h[mid] > h[i]) mid = i;
	int lc = solve(l, mid-1, h[mid]), rc = solve(mid+1, r, h[mid]);
	for(Rint i = 0;i <= mid-l;++ i)
		for(Rint j = 0;j <= r-mid;++ j){
			int tmp = (LL) f[lc][i] * f[rc][j] % mod;
			qmo(f[mid][i+j] += tmp - mod); qmo(f[mid][i+j+1] -= tmp); qmo(g[mid][i+j+1] += tmp - mod);
			qmo(g[mid][i+j] += (LL) (f[lc][i] + g[lc][i]) * (f[rc][j] + g[rc][j]) % mod - mod); qmo(g[mid][i+j] -= tmp);
		}
	for(Rint i = 0;i <= r-l+1;++ i){
		f[mid][i] = (LL) f[mid][i] * ksm(pw2[r-l+1-i], h[mid] - val) % mod;
		g[mid][i] = (LL) g[mid][i] * ksm(pw2[r-l+1-i]-1, h[mid] - val) % mod;
	} return mid;
}
int main(){
	read(n); pw2[0] = f[0][0] = 1;
	for(Rint i = 1;i <= n;++ i){read(h[i]); qmo(pw2[i] = (pw2[i-1]<<1) - mod);}
	int rt = solve(1, n, 0);
	for(Rint i = 0;i <= n;++ i){qmo(ans += f[rt][i] - mod); qmo(ans += g[rt][i] - mod);}
	printf("%d\n", ans);
}