#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=405,mod=998244353;
const ll mod2=(ll)mod*mod*8;
ll F[N][N],G[N][N],ff[N],gg[N],pw[N];
int sz[N],n,h[N],q[N],ch[N][2],f[N],g[N];
inline void add(ll &a,ll b){
	a+=b; if(a>=mod2)a-=mod2;
}
void dfs(int p,int H){
	sz[p]=1;
	F[p][0]=1; G[p][0]=1; G[p][1]=mod-1;
	For(i,0,1)if(ch[p][i]){
		int v=ch[p][i];
		dfs(v,h[p]);
		For(j,0,sz[p]){
			For(k,0,sz[v]){
				add(ff[j+k],F[p][j]*F[v][k]);
				add(gg[j+k],G[p][j]*G[v][k]);
			}
		}
		sz[p]+=sz[v];
		For(j,0,sz[p]){
			F[p][j]=ff[j]%mod; G[p][j]=gg[j]%mod; ff[j]=gg[j]=0;
		}
	}
	For(i,1,h[p]-H){
		For(j,1,sz[p]){
			F[p][j]=(F[p][j]*(pw[sz[p]-j]-1)+G[p][j])%mod;
			G[p][j]=G[p][j]*pw[sz[p]-j]%mod;
		}
		F[p][0]=F[p][0]*pw[sz[p]]%mod;
		G[p][0]=G[p][0]*pw[sz[p]]%mod;
	}
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,1,n)h[i]=read();
	For(i,pw[0]=1,n)pw[i]=pw[i-1]*2%mod;
	int top=0;
	For(i,1,n+1){
		while(h[q[top]]>h[i])g[q[top--]]=i;
		f[i]=q[top]; q[++top]=i;
	}
	For(i,1,n)if(h[f[i]]<=h[g[i]])ch[g[i]][0]=i; else ch[f[i]][1]=i;
	int rt=ch[n+1][0]; 
	dfs(rt,0);
	ll ans=0;
	For(i,0,n)ans+=F[rt][i];
	cout<<ans%mod<<endl;
}
/*
F[i][j] 表示 i 子树，有 j 列禁止点
G[i][j] 表示 i 子树，最下面放了 j 列禁止点 
*/
