Cheeseburgers are serious business. They are the most delicious food on earth, but there is a lot of room for error when making one. Even otherwise capable cooks often mess up the order of the assembled ingredients.
The only correct order of ingredients between the buns is, from top to bottom:
Any deviation from this order is completely unacceptable, so a cheeseburger sometimes has to be reassembled.
Space on an average plate and social norms are rather restrictive when it comes to operating on a cheeseburger. The only feasible operation is the bit-shuffle (burger-ineptly-transformed). A bit-shuffle separates the entire burger into four parts of contiguous ingredients a, b, c, d and reassembles them in the order c, a, d, b. You pick the size of each of the four parts, and a part may be empty.
Since the burger cools rapidly, find the minimum number of bit-shuffles needed to arrive at an acceptable burger.
Each given cheeseburger consists of n unique ingredients labeled from 1 to n. The correct order is always the natural order 1,2,…,n.

Figure 1: an illustration of the first sample input.

Figure 2: an illustration of the second sample input.
The first line contains one integer n, the number of ingredients used (1≤n≤10).
The second line contains n integers describing the order of the ingredients of the given cheeseburger, from top to bottom. The ingredients are numbered from 1 to n, and every number appears exactly once.
Output the minimum number of bit-shuffles needed to correct the given cheeseburger.