New Professor

면접 대비

시간 제한1초메모리 제한2048 MB

요약
색깔별 셔츠 개수가 주어질 때, 연속한 5일마다 서로 다른 색 5개를 입는 조건을 지키며 며칠까지 입을 수 있는지 구한다.
난이도

보통10점 중 6점

유형
그리디, 수학, 구현, 이분 탐색
정답자
아직 제출이 없습니다

문제

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 CC 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 CC colors, how many days can Blake go before breaking the rule of wearing 55 different colors of shirts in a single week?

Note that a work week is 55 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 1≤C≤5001 \leq C \leq 500 representing the number of colors.

Each of the next CC lines contain an integer 1≤S_i≤5001 \leq S\_i \leq 500 representing the number of shirts that Blake has of the ithi^{\text{th}} 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.

예제3

  1. 예제 1

    입력
    3
    4
    4
    3
    
    예상 출력
    3
    
  2. 예제 2

    입력
    6
    4
    2
    2
    2
    2
    3
    
    예상 출력
    14
    
  3. 예제 3

    입력
    5
    3
    3
    4
    3
    2
    
    예상 출력
    14