What is wrong in my approach in Second largest Element question of ENCODER, NIT Kurukshetra

The question is here --> Question
and this is my code in python3:

for i in range(int(input())):

x,y = map(int,input().split())
arr = [int(i) for i in input().split()]
i=0
curr = 'N'
all_m = 0
count=0
ind=0
while i<len(arr):
    i = ind
    while i<len(arr):
        if arr* >y and arr*!=curr:
            if curr!='N':
                ind = arr.index(curr)+1
                all_m = max(all_m,count)
                curr = arr*
                count= i - (ind-1)
            else:
                curr = arr*
                count+=1
        else:
            count+=1
        i+=1
all_m = max(all_m,count)
print(all_m)