n = int(input()) A = list(map(int, input().split())) for d in range(1, 3): for i in range(n-d): if A[i] == A[i+d]: print("Yes") exit() print("No")