import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline def kado(x,y,z): if x==z: return 0 if yx and y>z: return 1 return 0 T=int(input()) for tests in range(T): N=int(input()) A=list(map(int,input().split())) NO=[] for i in range(1,N-1): if kado(A[i-1],A[i],A[i+1])==0: NO.extend([i-3,i-2,i-1,i,i+1,i+2,i+3]) NO=sorted(set(NO)) flag=0 if len(NO)<=500: for x in NO: if flag==1: break if x<0 or x>=N: continue for i in range(N): if flag==1: break if x==i: continue A[x],A[i]=A[i],A[x] for a in NO+list(range(x-5,x+6))+list(range(i-5,i+6)): if a<=0 or a>=N-1: continue if kado(A[a-1],A[a],A[a+1])==0: break else: print("Yes") flag=1 break A[x],A[i]=A[i],A[x] if flag==0: print("No")