Hide

Problem D
New Professor

After successfully defending their PhD, Blake got a job as a professor at CS@Mines. Because this is their first semester teaching, they want to look as sharp as possible. Luckily, they have a large wardrobe full of shirts in $C$ different colors.

Blake decides to wear a different color of shirt each day of the work week (Monday through Friday). Additionally, Blake hates doing laundry, so they only wear a shirt once before throwing it away. (Blake is OK with wearing the same color of shirt on Friday of one week and Monday of the next week.)

Given the number of shirts of each of the $C$ colors, how many days can Blake go before breaking the rule of wearing $5$ different colors of shirts in a single week?

Note that a work week is $5$ days (Monday, Tuesday, Wednesday, Thursday, Friday) and it is ok to wear the same color on Friday of a week and Monday of next consecutive week.

Input

The first line of input is a single integer $1 \leq C \leq 500$ representing the number of colors.

Each of the next $C$ lines contain an integer $1 \leq S_ i \leq 500$ representing the number of shirts that Blake has of the $i^{\text {th}}$ unique color.

Output

Your output should be a single line, containing a single integer, the number of days that Blake can wear a different shirt before repeating themself.

Sample Input 1 Sample Output 1
3
4
4
3
3
Sample Input 2 Sample Output 2
6
4
2
2
2
2
3
14
Sample Input 3 Sample Output 3
5
3
3
4
3
2
14

Please log in to submit a solution to this problem

Log in