n = int(input()) arr = list(map(int,input().split())) x,y = map(int,input().split()) if x not in arr or y not in arr: print('No') if arr[arr.index(x)-1] == y or arr[arr.index(x)+1] == y: print('Yes') else: print('No')
n = int(input()) arr = list(map(int,input().split())) x,y = map(int,input().split()) if x not in arr or y not in arr: print('No') if arr[arr.index(x)-1] == y or arr[arr.index(x)+1] == y: print('Yes') else: print('No')