import sys
N = int(input())
a_lis = [int(_) % 2 for _ in input().split()]

first = [0, 1, 1]
second = [1, 0, 1]
third = [1, 1, 0]

if set(a_lis) == {0}:
    print('Yes')
    sys.exit()
else:
    if len(a_lis) % 3 == 0:
        ans_lis = [0] * (len(a_lis) // 3)
        for i in range(len(ans_lis)):
            if i >= 1:
                if tmp != a_lis[3 * i: 3 * (i + 1)]:
                    print('No')
                    sys.exit()
            else:
                tmp = a_lis[3 * i: 3 * (i + 1)]
        print('Yes')
                
    else:
        print('No')
        sys.exit()