from collections import defaultdict from itertools import repeat import sys import os sys.setrecursionlimit(100000) is_local = "TERM_PROGRAM" in os.environ input = sys.stdin.readline INF = float('inf') MOD = 998244353 def debug(*args, **kwargs): if is_local: print(*args, **kwargs) def I(): return input().rstrip() def IS(): return input().split() def II(): return int(input()) def IIS(): return map(int, input().split()) def LIIS(): return list(map(int, input().split())) jun_map = {0: 1, 1: 2, 2: 0} rev_map = {0: 2, 2: 1, 1: 0} def main(): n = II() va = LIIS() rev = n % 2 == 0 one_array = [0] two_array = [0] cnt = 0 for _ in range(2*n): one_array.append(step(one_array[-1], rev)) two_array.append(step(two_array[-1], not rev)) cnt += 1 if cnt == 2: rev = not rev cnt = 0 one_array2 = [] one_array3 = [] two_array2 = [] two_array3 = [] for i in range(2*n+1): one_array2.append(jun_map[one_array[i]]) one_array3.append(rev_map[one_array[i]]) two_array2.append(jun_map[two_array[i]]) two_array3.append(rev_map[two_array[i]]) if va == one_array or va == one_array2 or va == one_array3: print(1) elif va == two_array or va == two_array2 or va == two_array3: print(2) else: print(0) def step(x, rev): if rev: return rev_map[x] else: return jun_map[x] if __name__ == "__main__": main()