New Professor
면접 대비시간 제한1초메모리 제한2048 MB
색깔별 셔츠 개수가 주어질 때, 연속한 5일마다 서로 다른 색 5개를 입는 조건을 지키며 며칠까지 입을 수 있는지 구한다.
문제
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 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 colors, how many days can Blake go before breaking the rule of wearing different colors of shirts in a single week?
Note that a work week is 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.
입력
The first line of input is a single integer representing the number of colors.
Each of the next lines contain an integer representing the number of shirts that Blake has of the unique color.
출력
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.