#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int mo=998244353;
const int N=405;
int n,a[N],C[N][N],P[N];
int lson[N*2],rson[N*2];
int val[N*2],len[N*2],nd;
int f[N*2][N],g[N*2][N];
int tf[N],tg[N];
void init(){
	For(i,0,N-1) C[i][0]=1;
	For(i,1,N-1) For(j,1,i) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
	For(i,(P[0]=1),N-1) P[i]=2ll*P[i-1]%mo;
}
int build_tr(int l,int r){
	if (l>r) return 0;
	int p=l,k=++nd;
	For(i,l,r) if (a[i]<a[p]) p=i;
	val[k]=a[p]; len[k]=r-l+1;
	lson[k]=build_tr(l,p-1);
	rson[k]=build_tr(p+1,r);
	return k;
}
void get_ans(int x,int lad){
	if (!x) return;
	int sz=len[x];
	int ls=lson[x],n=len[ls];
	int rs=rson[x],m=len[rs];
	get_ans(ls,val[x]);
	get_ans(rs,val[x]);
	For(i,0,n) For(j,0,m){
		f[x][i+j]=(f[x][i+j]+1ll*f[ls][i]*f[rs][j])%mo;
		f[x][i+j+1]=(f[x][i+j+1]+1ll*f[ls][i]*f[rs][j])%mo;
		g[x][i+j+1]=(g[x][i+j+1]+1ll*g[ls][i]*g[rs][j])%mo;
	}
	For(T,1,val[x]-lad){
		memset(tf,0,sizeof(tf));
		memset(tg,0,sizeof(tg));
		For(j,0,sz){
			tf[j]=(tf[j]+g[x][j])%mo;
			tg[j]=(tg[j]+g[x][j])%mo;
			For(k,0,sz-j){
				int dif=1ll*P[j]*C[j+k][k]%mo;
				if (!k) dif=(dif+mo-1)%mo;
				tf[j]=(tf[j]+1ll*dif*f[x][j+k])%mo;
				tg[j]=(tg[j]+1ll*dif*g[x][j+k])%mo; 
			}
		}
		memcpy(f[x],tf,sizeof(tf));
		memcpy(g[x],tg,sizeof(tg));
	}
}
int main(){
	init();
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	int rt=build_tr(1,n);
	f[0][0]=g[0][0]=1; 
	get_ans(rt,0);
	printf("%d\n",f[rt][0]);
}
