max input while max seq map int raw_input split tail appendix for truc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
max=input()
while max:
seq=map(int, raw_input().split())
tail=0
appendix=[]
for truck in seq:
if truck==tail+1: tail=truck
else: appendix.append(truck)
while appendix:
if appendix[-1]==tail+1: tail=appendix.pop()
else: break
if appendix: print 'no'
else: print 'yes'
max=input()