n = int(input()) A = list(map(int,input().split())) for i in range(2*n-1): x,y,z = A[i],A[i+1],A[i+2] if (x,y,z) in ((0,1,2),(1,2,0),(2,0,1)): A[i] = 1 elif (x,y,z) in ((0,2,1),(2,1,0),(1,0,2)): A[i] = 2 else: A[i] = 0 n -= 1 if n%2: one = [2,0,1,0]*(n//2)+[2,0,1] two = [1,0,2,0]*(n//2)+[1,0,2] else: one = [1,0,2,0]*(n//2)+[1] two = [2,0,1,0]*(n//2)+[2] if A[:-2] == one: print(1) elif A[:-2] == two: print(2) else: print(0)