#agc043b. [agc043_b]123 Triangle

[agc043_b]123 Triangle

Problem Statement

Given is a sequence of NN digits a1a2ldotsaNa_1a_2\\ldots a_N, where each element is 11, 22, or 33. Let xi,jx_{i,j} defined as follows:

  • x1,j:=ajx_{1,j} := a_j quad\\quad (1leqjleqN1 \\leq j \\leq N)
  • xi,j:=xi1,jxi1,j+1x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | quad\\quad (2leqileqN2 \\leq i \\leq N and 1leqjleqN+1i1 \\leq j \\leq N+1-i)

Find xN,1x_{N,1}.

Constraints

  • 2leqNleq1062 \\leq N \\leq 10^6
  • ai=1,2,3a_i = 1,2,3 (1leqileqN)(1 \\leq i \\leq N)

Input

Input is given from Standard Input in the following format:

NN a1a_1a2a_2ldots\\ldotsaNa_N

Output

Print xN,1x_{N,1}.


Sample Input 1

4
1231

Sample Output 1

1

x1,1,x1,2,x1,3,x1,4x_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,11,2,3,1.

x2,1,x2,2,x2,3x_{2,1},x_{2,2},x_{2,3} are respectively 12=1,23=1,31=2|1-2| = 1,|2-3| = 1,|3-1| = 2.

x3,1,x3,2x_{3,1},x_{3,2} are respectively 11=0,12=1|1-1| = 0,|1-2| = 1.

Finally, x4,1=01=1x_{4,1} = |0-1| = 1, so the answer is 11.


Sample Input 2

10
2311312312

Sample Output 2

0