#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define db long double
#define mp make_pair
#define X first
#define Y second
#define vi vector<int>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<(a).size();++i)
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
#define gc getchar
inline ll rd()
{
	ll x=0,w=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();
	if(c=='-')c=gc(),w=-1;while(isdigit(c))x=x*10+c-48,c=gc();return x*w;
}
const int N=405,P=998244353;
int n,tt,h[N],f[N][N][2],g[N][2],p[2][N][N];
int dp(int l,int r)
{
	if(l>r)return 0;int o=++tt,val=1e9,nn=0;
	rep(i,l,r)val=min(val,h[i]);
	int lst=l-1,sz=0;f[o][0][0]=1;
	rep(i,l,r+1)if(i==r+1||h[i]==val)
	{
		nn++;int t=dp(lst+1,i-1);
		if(t)
		{
			memset(g,0,sizeof(g));
			rep(s1,0,sz)rep(s2,0,i-lst-1)rep(t1,0,1)rep(t2,0,1)
				g[s1+s2][t1|t2]=(g[s1+s2][t1|t2]+1ll*f[o][s1][t1]*f[t][s2][t2])%P;
			memcpy(f[o],g,sizeof(g));sz+=i-lst-1;
		}
		lst=i;
	}
	nn--;
	rep(i,1,nn)
	{
		memcpy(g,f[o],sizeof(g));
		rep(j,0,r-l+1)g[j+1][0]=(g[j+1][0]+P-f[o][j][0])%P;
		rep(j,0,r-l+1)g[j+1][1]=(g[j+1][1]+f[o][j][0])%P;
		memcpy(f[o],g,sizeof(g));
	}
	int len=val-max(h[l-1],h[r+1]);
	rep(i,0,r-l+1)
	{
		f[o][i][0]=1ll*f[o][i][0]*p[0][r-l+1-i][len]%P;
		f[o][i][1]=1ll*f[o][i][1]*p[1][r-l+1-i][len]%P;
	}
	return o;
}
int main()
{
	n=rd();rep(i,1,n)h[i]=rd();
	rep(i,0,n)p[0][i][0]=p[0][0][i]=1;
	rep(j,1,n)
	{
		p[0][j][1]=2ll*p[0][j-1][1]%P;p[1][j][1]=p[0][j][1]-1;
		rep(k,2,n)p[0][j][k]=1ll*p[0][j][k-1]*p[0][j][1]%P;
		rep(k,2,n)p[1][j][k]=1ll*p[1][j][k-1]*p[1][j][1]%P;
	}
	int t=dp(1,n),s=0;
	rep(i,0,n)rep(j,0,1)s=(s+f[t][i][j])%P;
	printf("%d\n",s);return 0;
}
