Reinaldo is a driver who works in the city of São Paulo, starting his demanding routine every day at 5:00 AM. He must visit $$$N$$$ different locations in order to complete his work. Despite São Paulo's traffic, Reinaldo always takes the same amount of time: $$$T_1$$$ minutes to travel from his home to the first location, $$$T_2$$$ minutes to travel from the first location to the second, and so on.
The problem is that on one day of the week, the city of São Paulo enforces a vehicle restriction system based on license plate numbers. Under this system, Reinaldo is not allowed to drive between 7:00 AM and 10:00 AM, nor between 5:00 PM and 8:00 PM. Whenever one of these restricted periods begins while Reinaldo is driving, he must stop his car wherever he is and resume driving only after the restriction period ends.
Can you help Reinaldo determine how long it will take him to complete his work routine on a day when the license plate restriction is in effect?
The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 12$$$).
The second line contains $$$N$$$ integers $$$T_i$$$ ($$$1 \leq T_i \leq 120$$$ minutes), representing the travel times between consecutive locations.
The output should contain a single line with an integer representing the number of minutes Reinaldo takes to complete his work routine.
360 30 30
120
360 30 31
301
570 60 30 40 30
410
6100 100 100 100 100 100
960
Explanation of Sample 1: The three trips take a total of 2 hours (120 minutes). Therefore, Reinaldo starts at 5:00 AM and finishes at 7:00 AM without having to stop because of the driving restriction.
Explanation of Sample 2: The three trips take a total of 121 minutes, forcing Reinaldo to stop during the restriction period between 7:00 AM and 10:00 AM. As a result, the total time becomes 301 minutes.
| Name |
|---|


