#K4456. Maximum Product Selection

    ID: 27558 Type: Default 1000ms 256MiB

Maximum Product Selection

Maximum Product Selection

You are given an array of n integers. Your task is to determine the maximum product that can be obtained by selecting either:

  • Three integers from the array, or
  • Two integers from the array and the integer \(1\)

You should output a single integer — the maximum product achievable according to the criteria above.

Note: The \(1\) in the second option is a constant and does not have to be present in the array. The input ensures that the array always contains at least three integers.

inputFormat

The first line contains an integer \(n\) representing the number of elements in the array.

The second line contains \(n\) space-separated integers.

All input is provided via stdin.

outputFormat

Output a single integer — the maximum product obtainable. The output should be printed to stdout.

## sample
5
1 10 2 6 -1
120

</p>