#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=509,mod=998244353;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	int f[N][N],g[N][N],h[N],n,pw[N];
	inline int get(int l,int r,int bas){
		if(l>r) return 0;
		
		int mid=l,ls,rs;
		for(int i=l+1;i<=r;i++) if(h[i]<h[mid]) mid=i;
		ls=get(l,mid-1,h[mid]),rs=get(mid+1,r,h[mid]);
		int lenl=mid-l,lenr=r-mid;

		for(int i=0;i<=lenl;i++)
			for(int j=0;j<=lenr;j++){
				int a=1LL*f[ls][i]*f[rs][j]%mod;
				int b=(1LL*add(f[ls][i],g[ls][i])*g[rs][j]+1LL*g[ls][i]*f[rs][j])%mod;
				f[mid][i+j]=add(f[mid][i+j],a);
				f[mid][i+j+1]=sub(f[mid][i+j+1],a);
				g[mid][i+j]=add(g[mid][i+j],b);
				g[mid][i+j+1]=add(g[mid][i+j+1],a);
			}
		
		for(int i=0;i<=r-l+1;i++){
			f[mid][i]=1LL*f[mid][i]*qpow(pw[r-l+1-i],h[mid]-bas)%mod;
			g[mid][i]=1LL*g[mid][i]*qpow(sub(pw[r-l+1-i],1),h[mid]-bas)%mod;
		}
		return mid;
	}

	int main(){
		f[0][0]=1,n=read<int>();
		for(int i=1;i<=n;i++) h[i]=read<int>();

		pw[0]=1;
		for(int i=1;i<=n;i++) pw[i]=add(pw[i-1],pw[i-1]);
		int rt=get(1,n,0),ans=0;
		for(int i=0;i<=n;i++) ans=add(ans,add(f[rt][i],g[rt][i]));
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}