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 System.Threading; using System.Runtime.CompilerServices; using System.Diagnostics; //using nint=System.Int32; static class Program{ const int mod=(int)1e9+7; static void Main(){ Sc sc=new Sc(); var (n,k)=sc.Tp2(); var a=sc.Ia; var db=new Db(n,31,true); for(int i = 0;i=n){db.Ud(i,n);} } db.Go(); StringBuilder sb=new StringBuilder(); for(int i = 0;i comp; public Db(int n,bool b){ this.n=n; m=(int)Log(n,2)+2; d=new int[m][]; d[0]=new int[n]; c=new long[n]; if(b){comp=CoMax;o=-1;} else{comp=CoMin;o=1;} } public Db(int n,int m,bool b){ this.n=n; this.m=m; d=new int[m][]; d[0]=new int[n]; c=new long[n]; dp=new long[m][]; dp[0]=new long[n]; if(b){comp=CoMax;o=-1;} else{comp=CoMin;o=1;} } [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool CoMax(long x,long y){return x>y;} [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool CoMin(long x,long y){return x=0;i--) { if((x&(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(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]));} public (T,T,T) Tp3(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]),Ct(s[2]));} public (T,T,T,T) Tp4(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]),Ct(s[2]),Ct(s[3]));} public (T1,T2) Tp2(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]));} public (T1,T1,T2) Tp3(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]),Ct(s[2]));} private T Ct(string s){return (T)Convert.ChangeType(s,typeof(T));} }