n=int(input()) a=[0]+list(map(int,input().split())) for i in range(1,n-1): if a[i] == a[i+2]: print('Yes') exit() print('No')