n = int(input()) a = list(map(int,input().split())) che = False for i in range(2, n): if a[i - 2] == a[i]: che = True break print('Yes') if che else print('No')