def solve(): n=int(input()) a=list(map(int,input().split())) a+=a[0:2] isK=[a[i]!=a[i+2]and((a[i]a[i+2])or(a[i]>a[i+1]and a[i+1]=2and isK[j+i-2]and res