Help may lunch time

may lunchtime - question - birthday gift | TWINGFT

My codes run perfectly, with all test cases right, and with the time constraints and i even checked the various different test cases with codechef official editorial code. and the results are matching perfectly… can anyone help me why is it still showing the Wrong Answer… please …

here is the code : -

t =int(input())
while(t>0):
t -= 1
n,k = map(int,input().split())
a = [n]
a = list(map(int, input().split()))
a.sort()
a.reverse()
chef = 0
p = 0
for i in range(0,k2):
if(i == 0 and a[i]==a[i+1]):
p = -1
continue
elif(2
k-i==1 and p == -1):
chef += a[i] + a[i+1]
elif(i%2==1 ):
if(p == 0 or p == -1):
chef += a[i]
else:
p = -1
continue
elif(chef==0 or i%2==0):
chef += a[i]
p = 1
print(chef)

python