def f(a,b,c): if (a,b,c) in ((0,1,2),(1,2,0),(2,0,1)):return 1 elif (a,b,c) in ((2,1,0),(1,0,2),(0,2,1)):return 2 else:return 0 N = int(input()) A = list(map(int,input().split())) N_2 = N-1 A_2 = [] for i in range(2*N-1): A_2.append(f(A[i],A[i+1],A[i+2])) if N_2%2==0: one = [1,0,2,0]*(N_2//2)+[1] two = [2,0,1,0]*(N_2//2)+[2] else: one = [2,0,1,0]*(N_2//2)+[2,0,1] two = [1,0,2,0]*(N_2//2)+[1,0,2] print(1 if A_2==one else 2 if A_2==two else 0)