A cake walk problem :
however I would like to know why the following solution using pop doesn’t work?
for tc in range(int(input())):
size_array = int(input()) #Just for the heck of it
a1 = list(map(int,input().split(' ')))
i = 0
cost = 0
while len(a1)!=1:
if a1[i]>a1[i+1]:
cost = cost + a1[i+1]
a1.pop(i)
elif a1[i]<a1[i+1]:
cost = cost + a1[i]
a1.pop(i+1)
print(cost)