Seven-legged spiders living in Bajtocja build webs with a very regular structure. Such a web consists of one central node, where the spider usually rests, and d rings numbered from 1 to d. Each ring is a single cycle of nodes connected by threads.
Every node except those on ring d is connected by threads to exactly seven other nodes. The central node is connected to all seven nodes of ring 1. Each node of ring i is connected to k∈{1,2} nodes of ring i−1, to its two neighbours on ring i, and to l=5−k consecutive nodes of ring i+1. The first and the last of these l nodes are each connected to two adjacent nodes of ring i, while the others are connected to only one. Such a web can always be drawn in the plane so that no two threads cross. The figure below illustrates the structure.

These webs are very effective. Recently Bajtazar observed a spider walking on a web with d=109 rings. The spider started at the central node and then, moving along the threads, returned to its starting point without passing through any node more than once. The route traced out a closed polygon, and in every node strictly inside that polygon a fly was caught. Bajtazar wrote down the spider's successive moves and would like to compute how many flies were caught.
The first line contains one integer n (3≤n≤7777777), the length of the spider's walk, that is, the number of nodes it visited.
The second line contains n integers z1,z2,…,zn (1≤zi≤6) describing the successive turns the spider made. At the i-th node of the route the spider left along the zi-th thread counted clockwise, where thread 0 is the thread by which the spider entered that node. The value z1 refers to the first node reached after leaving the central node, and zn describes the turn the spider would have to make at the central node in order to traverse the whole route once more.
Print one integer: the number of web nodes strictly inside the polygon that the spider walked around. Nodes lying on the boundary of the polygon are not counted.

The polygon in the figure shows the spider's route. There are two nodes strictly inside it. Note that nodes lying on the boundary of the polygon are not counted. (This figure corresponds to the sample input below.)