#C9580. Latest Common Stop Time

    ID: 53689 Type: Default 1000ms 256MiB

Latest Common Stop Time

Latest Common Stop Time

Given a list of work durations for different workers, determine the latest time at which all workers can simultaneously stop working if we are allowed to reduce any worker's duration as needed.

In other words, you are provided with the scheduled work durations. While you cannot extend a worker's assigned time, you can reduce a longer duration so that all workers finish at the same moment. The goal is to find the maximum possible simultaneous stop time. Under these conditions, it turns out that the optimal strategy is to choose the worker with the longest scheduled duration.

Note: Although it might seem that the worker with the smallest duration would constrain the finish time, since extending is not allowed while reducing is, the answer is simply the maximum duration among those given.

For example:

  • If the input durations are 300 150 200 400, the answer is 400.
  • If the input durations are 100 200 300, the answer is 300.

inputFormat

The input is provided via standard input (stdin) and consists of two lines:

  1. The first line contains a single integer n (1 ≤ n ≤ 105) representing the number of workers.
  2. The second line contains n space-separated integers, where each integer represents the work duration for a worker. Each duration is a positive integer.

outputFormat

The output should be a single integer printed to standard output (stdout) representing the latest possible stop time when all workers finish simultaneously.

## sample
4
300 150 200 400
400