def solution(priorities, location):
temp = []
count = 0
for i, v in enumerate(priorities):
temp.append({i: v})
# print(temp)
while temp:
now = temp.pop(0)
target = list(now.values())[0]
if target >= max(priorities):
priorities.remove(target)
count += 1
if list(now.keys())[0] == location:
return count
else:
temp.append(now)