eolymp
bolt
Try our new interface for solving problems
Problems

A box of chocolate

A box of chocolate

\includegraphics{https://static.e-olymp.com/content/a3/a33b157993743d464c6f15273464daae38764651.jpg} Vite birthday gave a huge box of chocolates. Each candy is made in the form of a round of chocolate coins wrapped in gold or silver foil. Victor - not a greedy boy, so he decided to share candy with her younger sister Masha. Victor called Masha and invited her to choose the most chocolate. And that was interesting, Victor Manechka allowed to choose any chocolate, but so that this choice satisfies the following rules: \begin{enumerate} \item All chocolates are rigorously horizontally. \item Each chocolate is either on the surface of the table, or on the other chocolates. Thus, some chocolates may form a pile. \item All selected chocolates should be in a heap. \item In a handful of each chocolate is allowed to put a bar of chocolate or a smaller radius, or four chocolate bars, but so that their edges are not performed by the edges of the chocolate, where they lie. \end{enumerate} Of course, Masha loves chocolate, so she wants to take the largest possible number of them. Very interesting how it got chocolate? Chocolates in the box so much that Victor is not afraid that if Manechka will fold hill chocolates, they may not be enough. For example, if a box of chocolate are the radii of \textbf{9}, \textbf{3}, \textbf{2} and \textbf{1}, then at the bottom tier can put the first piece of chocolate radius \textbf{9}, at her - four chocolates radius \textbf{3}, and each of them - four chocolates radius \textbf{1}. Total, \textbf{1} + \textbf{4} + \textbf{4}*\textbf{4} = \textbf{21} bar of chocolate. \textbf{Input } In the first line of the input file is written the number \textbf{N} (\textbf{0} ≤ \textbf{N} ≤ \textbf{1000}) - the number of types of chocolates in a box. The next line contains \textbf{N} integers - the radii of chocolates, each value does not exceed \textbf{10000}. \textbf{Output} Display the maximum number of chocolates, which can take Manechka.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4 
3 9 2 1
Output example #1
21