N = int(input()) A = list(map(int, input().split())) print("Yes" if all(A[i - 1] == 1 or A[i] == 1 or A[i + 1] == 1 for i in range(1, N - 1)) else "No")