C. Wedding Cake
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In a not-so-far dystopian future, people are paired with their soulmates via machine learning algorithms. This has streamlined the process of marriage so much that Mel, a baker, can't keep up with all the orders for wedding cakes, and he needs your help!

Mel's cakes are constructed with 5 layers, and each cake must be constructed in order (layer 2 can only be created after layer 1 is placed, layer 3 can only be created after layer 2 is placed, and so on). Each day, Mel gets the ingredients for one layer, which he can use to continue building one cake. He can also choose to not build that layer, but if he doesn't the ingredients spoil and he can't use them later!

Mel is good at multitasking so he can build many cakes simultaneously. Given the layer ingredients Mel gets for $$$N$$$ days, how many cakes can Mel complete, assuming he starts with nothing?

Input

The first line contains a single integer $$$N$$$ ($$$1 \le N \le 10^6$$$), denoting the number of days Mel will get ingredients.

The next line contains $$$N$$$ integers $$$a_1,...,a_N$$$ ($$$1 \le a_i \le 5$$$), where Mel can build layer $$$a_i$$$ on the $$$i$$$th day, if he chooses.

Output

Output one integer, the number of cakes Mel can finish.

Example
Input
11
1 1 2 3 4 4 5 2 3 4 5
Output
2
Note

In the first example, Mel can construct two cakes; one with ingredients from days 1, 3, 4, 5, and 7; and another with ingredients from days 2, 8, 9, 10, and 11.