K. Rotation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have $$$n$$$ stone statues, each with a nose. The statues can face $$$4$$$ directions: front, right, back, or left.

Each time you can either:

  • Press the nose of one statue, causing all other statues to rotate $$$90^{\circ}$$$ clockwise simultaneously; or
  • Press your own nose, causing all statues to rotate $$$90^{\circ}$$$ clockwise.
The clockwise rotation sequence is: front $$$\rightarrow$$$ right $$$\rightarrow$$$ back $$$\rightarrow$$$ left.

What is the minimum number of presses needed to make all statues face front?

Input

The first line contains an integer $$$n$$$ ($$$1\leq n\leq 10^6$$$).

The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$a_i\in\{0,1,2,3\}$$$) representing directions, $$$a_i=0,1,2,3$$$ correspond to front, right, back, left respectively.

Output

A single integer representing the answer.

Example
Input
4
0 1 2 3
Output
6