using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program{ const int mod=(int)1e9+7; const double eps=1e-11; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; var a=new long[s[0]]; var dp=new long[s[0]]; for(int i = 0;i=0;i--) { dp[i]=a[i]; for(int j = i+2;j Fu; public Spt(long[] a,bool bo){ int n=a.Length,m=(int)Log(n,2)+1; d=new long[m][]; d[0]=new long[n]; l=new int[n+1]; if(bo){Fu=(y,x)=>Max(y,x);} else{Fu=(y,x)=>Min(y,x);} for(int i=0;i>1]+1; } for(int i=1,k=1;ib){(a,b)=(b,a);} int p=l[b-a]; return Fu(d[p][a],d[p][b+1-(1<(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i