#include #define MIN(x,y) ((x)<(y)?(x):(y)) using namespace std; const int MOD=998244353; int main(){ int n; cin>>n; int a,b; cin>>b; long ans=1; for(int i=1;i>a; //前の列と次の列の小さいほうをかける ans=(ans*MIN(a,b))%MOD; b=a; } cout<