For this Question: Given an array A of N integers. You have to find whether A has some subsequence of length at least 3 that is a palindrome.First line of the input contains an integer N.
The second line of the input contains N space seperated integers.

Constraints:
1 <= N <= 5000
1 <= A<sub>i</sub> <= 10<sup>9</sup>Print "YES" if A has some subseqeuence of length at least 3 that is a palindrome, else print "NO", without the quotes.Sample Input:
5
1 5 2 2 1

Sample Output:
YES

Explanation:
We pick the elements at indices 1, 3, 4, 5 (1- indexed) making the subsequence: [1, 2, 2, 1], which is a palindrome., I have written this Solution Code: def sunpal(n,a):
    ok=False
    for i in range(n):
        for j in range(i+2,n):
            if a[i]==a[j]:
                ok=True
    return("YES" if ok else "NO")
if __name__=="__main__":
    n=int(input())
    a=input().split()
    res=sunpal(n,a)
    print(res), In this Programming Language: Python, Now tell me if this Code is compilable or not?