n = int(input()) a = list(map(int, input().split())) ok = False for i in range(1, n - 1): if a[i - 1] == a[i + 1]: ok = True print("Yes" if ok else "No")