Mutalisk 2

Given up to 20 SCVs with health, each attack deals 9, 3, and 1 damage to three distinct SCVs; find the minimum number of attacks to destroy all of them.

Medium7Dynamic programmingBit manipulationBacktrackingNo attempts yetTime limit2sMemory limit512 MB

Problem

Subin is playing StarCraft against Gangho. Subin has one Mutalisk left, and Gangho has NN SCVs left.

Each SCV has some remaining health and cannot attack the Mutalisk, so Subin has already won this game.

One attack of the Mutalisk hits at most three different SCVs. The amount of health lost is decided by the order in which the SCVs are hit.

  1. The SCV hit first loses 9 health.
  2. The SCV hit second loses 3 health.
  3. The SCV hit third loses 1 health.

An SCV whose health drops to 0 or below is destroyed at once. A single attack cannot hit the same SCV twice, and it cannot hit an SCV that is already destroyed.

Given the remaining health of every SCV, write a program that finds the minimum number of attacks needed to destroy all of them.

Input

The first line contains the number of SCVs NN (1N201 \le N \le 20). The second line contains the health of the NN SCVs, separated by spaces. Each health value is an integer between 11 and 6060.

Output

Print on one line the minimum number of attacks needed to destroy every SCV.