#K6566. Maximize Productivity

    ID: 32247 Type: Default 1000ms 256MiB

Maximize Productivity

Maximize Productivity

You are given an array of n positive integers. Your task is to remove exactly one element from the array such that the product of the remaining elements is maximized. In other words, if the array is \(a_1, a_2, \dots, a_n\) and you remove the element \(a_i\), then the resulting productivity will be:

\(\prod_{\substack{j=1 \\ j \neq i}}^n a_j\)

Find the maximum productivity obtainable by removing exactly one element, and print that value.

inputFormat

The input is read from stdin and consists of:

  • The first line contains a single integer n representing the number of elements in the array.
  • The second line contains n space-separated positive integers representing the elements of the array.

outputFormat

Output a single integer to stdout—the maximum product obtainable after removing exactly one element from the array.

## sample
4
1 2 3 4
24