def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 A = list(map(int, input[idx:idx+6])) A = A[:6] # Ensure we have exactly 6 elements if N == 0 or N == 1: print("NO") return elif N == 2: # V_2 has two elements: frozenset() and frozenset({frozenset()}) v0 = frozenset() v1 = frozenset({frozenset()}) V = [v0, v1] for m0 in V: for m1 in V: for m2 in V: a0 = A[0] a1 = A[1] a2 = A[2] a3 = A[3] a4 = A[4] a5 = A[5] # Get the corresponding m variables m_A0 = [m0, m1, m2][a0] m_A1 = [m0, m1, m2][a1] m_A2 = [m0, m1, m2][a2] m_A3 = [m0, m1, m2][a3] m_A4 = [m0, m1, m2][a4] m_A5 = [m0, m1, m2][a5] # Condition C0: m_A0 is subset of m_A1 c0 = True for x in m_A0: if x not in m_A1: c0 = False break # Condition C1: m_A1 in m_A2 c1 = m_A1 in m_A2 # Condition C2: m_A3 in m_A2 c2 = m_A3 in m_A2 # Condition C3: m_A4 in m_A2 c3 = m_A4 in m_A2 # Condition C4: m_A5 in m_A0 c4 = m_A5 in m_A0 if c0 and c1 and c2 and c3 and c4: print("YES") return print("NO") else: print("YES") if __name__ == "__main__": main()