import strutils, sequtils var n: int a: seq[int] dp: seq[seq[int]] t = stdin.readLine.parseInt proc nya(i, j: int) : int = if dp[i][j] != -1: return dp[i][j] result = 2 var x = a[j] - a[i] for k in j+1 .. 0 and y > 0 and x < y) or (x < 0 and y < 0 and x < y) or (x > 0 and y < 0): result = max(result, nya(j, k)+1) dp[i][j] = result for cases in 0 ..