I found an interesting problem on https://www.codechef.com/problems/XOMMON:
Given an array of n$n$ integers : A1,A2,...,An$ A_1, A_2,... , A_n$, find the longest size subsequence which satisfies the following property: The xor of adjacent integers in the subsequence must be non-decreasing.

-----Input:-----
- First line contains an integer n$n$, denoting the length of the array. 
- Second line will contain n$n$ space separated integers, denoting the elements of the array.

-----Output:-----
Output a single integer denoting the longest size of subsequence with the given property.

-----Constraints-----
- 1≤n≤103$1 \leq n \leq 10^3$
- 0≤Ai≤1018$0 \leq A_i \leq 10^{18}$

-----Sample Input:-----
8
1 200 3 0 400 4 1 7

-----Sample Output:-----
6

-----EXPLANATION:-----
The subsequence of maximum length is {1, 3, 0, 4, 1, 7} with Xor of adjacent indexes as {2,3,4,5,6} (non-decreasing)

I tried it in Python, but could not do it. Can you solve it?
# cook your dish here
n=int(input())
l=list(map(int,input().split()))
a=[]
for i in range(0,n):
    for j in range(i+1,n):
     a.append((l[i]^l[j],(i,j)))

a.sort()
dp=[0]*n
for i in range(0,len(a)):
    x=a[i][0]
    left,right=a[i][1][0],a[i][1][1]
    dp[right]=max(dp[left]+1,dp[right])

print(max(dp)+1)