module m implicit none integer::n integer::a(100),f(100,100) contains recursive integer function g(s,t)result(res) implicit none integer::s,t integer::i,j,k,dy if(f(s,t)>=0)then res=f(s,t) return end if res=2 dy=a(t)-a(s) do i=t+1,n if(dy>0.and.a(t)-a(s)0.and.a(i)a(t)-a(i).and.a(t)>a(i))then res=max(res,1+g(t,i)) end if end do f(s,t)=res end function end module program main use m implicit none integer::t,i,j,k,x,y,r,ans read*,t do i=1,t read*,n do j=1,n do k=j+1,n f(j,k)=-1 end do end do read*,(a(j),j=1,n) ans=1 do j=1,n do k=j+1,n ans=max(ans,g(j,k)) end do end do print*,ans end do end program