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-1,i,i+1]) NO=sorted(set(NO)) flag=0 if len(NO)<=50: for x in NO: if flag==1: break 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(i-2,i+3)): 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")