#P12275. Maximizing Daily Revenue per Worker

    ID: 14384 Type: Default 1000ms 256MiB

Maximizing Daily Revenue per Worker

Maximizing Daily Revenue per Worker

In the city of H, a manufacturing haven, factories can produce n different items. Some of these items can be sold at fixed market prices. There are two production methods available:

  • Method 1: A worker can produce any number of items y directly in one day.
  • Method 2: A worker can convert any number of items x into items y in one day, with the condition that \( x \le y \) (i.e. lower–numbered items can be processed into higher–numbered items).

The mayor wishes to maximize the daily revenue per worker. For each item indexed \(i\) (\(1 \le i \le n\)), its sale price is \(a_i\) (if the item is marketable). A worker may use either production method. Note that using Method 2 does not yield any extra advantage if the final item \(y\) can be produced directly with Method 1. Therefore, the maximum revenue per worker per day is given by

[ \max_{1 \le i \le n} a_i ]

Your task is to compute this maximum revenue.

inputFormat

The input consists of two lines:

  1. The first line contains a single integer \(n\) \( (1 \le n \le 10^5)\) representing the number of items.
  2. The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\) \( (-10^9 \le a_i \le 10^9)\) representing the sale price of each item. It is guaranteed that at least one item is marketable.

outputFormat

Output a single integer, which is the maximum revenue a worker can generate in one day.

sample

5
1 2 3 2 4
4