cswork / OAOpen practice workspace

TradeDeskOA #7

Last to Be Checked

EasyJudge-ready

Topics (AI-labelled)Simulation

Participants arrive at the times in moments. A single counter checks one person at a time, and each check takes a fixed 300 seconds; if the counter is idle, the check starts immediately, otherwise the person waits. Return the time at which the last participant finishes being checked.

The problem statement and the 300-second duration come from the fixed catalog statement; this site adds the line-based input/output protocol. The original explanation field mistakenly said "300 minutes", which conflicts with the statement's 300 seconds and the example output 1201; following the body text and the examples, this site uses 300 seconds.

Input

The first line is the number of people n, and the second line contains n space-separated integer arrival times in non-decreasing order. This site's bounds: 1≤n≤100000, 0≤moments[i]≤10^9.

Output

Output the integer time (in seconds) at which the last participant finishes being checked.

Example 1

Input:

4
1 6 9 502

Output:

1201

Example 2

Input:

2
0 1

Output:

600

Example 3

Input:

1
0

Output:

300

Editorial

Loading solution…