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; //using nint=System.Int32; static class Program{ const int mod=(int)1e9+7; const double eps=1e-11; static void Main(){ Sc sc=new Sc(); var n=sc.I; var a=sc.Ia; var st=new St[2]; st[0]=new St(10001,false,false,mod); st[1]=new St(10001,false,false,mod); for(int i = 0;i"n:"+n.ToString()+" d:"+d.ToString(); } private Dt[] dat; private int n,cnt; private bool ku; private Dt du; private Func compare; public St(int n,bool mm,bool ku,long df){ this.n=n; this.ku=ku; if(mm){du=new Dt(long.MinValue,-1);compare=CoMax;} else{du=new Dt(long.MaxValue,-1);compare=CoMin;} cnt=n<<1; dat=new Dt[cnt]; for(int i = cnt-1;i>=cnt-n;i--) {dat[i]=new Dt(df,n-cnt+i);} for(int i = cnt-n-1;i>0;i--) {dat[i]=dat[i<<1];} } private Dt CoMax(Dt x,Dt y){return x.d>y.d?x:y;} private Dt CoMin(Dt x,Dt y){return x.d1){dat[q>>=1]=compare(dat[q<<1],dat[(q<<1)+1]);} } public Dt Get(int l,int r){ Dt x=du; l+=n;r+=n; while(l<=r){ if((l&1)==1){x=compare(x,dat[l++]);} if((r&1)==0){x=compare(x,dat[r--]);} l>>=1;r>>=1; } return x; } } public class Sc{ public int I{get{return int.Parse(Console.ReadLine());}} public long L{get{return long.Parse(Console.ReadLine());}} public double D{get{return double.Parse(Console.ReadLine());}} public string S{get{return Console.ReadLine();}} public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}} public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}} public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}} public string[] Sa{get{return Console.ReadLine().Split();}} public object[] Oa{get{return Console.ReadLine().Split();}} public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}} public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);} public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}} public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);} public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}} public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);} public T[] Arr(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