n = '123454324' for i in range(0, len(n)-1): a = int(n[i]) b = int(n[i+1]) if abs(a-b) != 1: print('No') break else: print('Yes')