Asrit has $n$ packets of steamed bun slices, arranged in a row. The steamed bun slices come in $5$ different flavors: scallion, cumin, barbecue, numbing-spicy, and beef. For convenience, we denote the flavors by $1 \sim 5$, where the flavor of the $i$-th packet is $a_i$.
Every time Asrit eats a packet of steamed bun slices, he gains $1$ happiness point. However, always eating the same flavor is boring. Specifically, if Asrit first eats a packet with flavor $x$, and the next packet he eats immediately after has flavor $y$, he additionally gains $(y - x + 5) \bmod 5$ happiness points.
To make eating more enjoyable, Asrit decides to adjust the eating order. He processes each packet one by one according to the initial order. For the packet currently being processed, he chooses whether to move it to the end of the sequence. Note that a packet cannot be moved twice, otherwise it will break.
After processing all packets, Asrit will eat them one by one in the new order. What is the maximum happiness Asrit can obtain?
Input
The first line contains an integer $n$ $(1 \le n \le 10^5)$, representing the number of packets.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 5)$, representing the flavor of each packet.
Output
Output one line containing an integer, representing the maximum happiness Asrit can obtain.
Examples
Input 1
6 1 1 1 1 1 1
Output 1
6
Input 2
6 5 5 4 3 2 1
Output 2
26
Input 3
6 1 1 2 3 4 5
Output 3
15
Note
Explanation of Example $3$: Move the $1$-st and the $6$-th packets to the end; the final eating sequence is 1 2 3 4 1 5, which gives the maximum answer.