N=int(input())
for i in range(N):
  s=int(input())
  A=list(map(int,input().split()))
  A=[0]+A+[0]
  c=dict()
  for j in range(len(A)):
    c[A[j]]=j
  if c[s]==1 or c[s]==s:
    this=2
    ans=2
  else:
    this=3
    ans=3
  for j in range(s-1,0,-1):
    if (A[c[j]]>A[c[j]-1] and A[c[j]]>A[c[j]+1]):
      if c[j]==1 or c[j]==s:
        this+=1
      else:
        this+=2
    if (A[c[j]]<A[c[j]-1] and A[c[j]]<A[c[j]+1]):
      this-=2
    if A[c[j]-1]==0:
      if A[c[j]+1]>A[c[j]]:
        this-=1
    if A[c[j]+1]==0:
      if A[c[j]-1]>A[c[j]]:
        this-=1
    
    #print(this,"a")
    
    ans=max(ans,this)
  print(ans)