#K94137. Maximum Product of Two Numbers

    ID: 38575 Type: Default 1000ms 256MiB

Maximum Product of Two Numbers

Maximum Product of Two Numbers

Given an array of integers, your task is to compute the maximum product of two distinct elements from the array. In other words, find two different indices i and j (i ≠ j) such that the product a[i] × a[j] is maximized.

If the array contains fewer than two elements, output 0.

Note: The input is read from standard input and the result should be printed to standard output.

The formula for the product is given by:

\(result = \max_{i \neq j} \{a[i] \times a[j]\}\)

inputFormat

The input consists of two lines:

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

If n < 2, you should output 0.

outputFormat

Output a single integer, the maximum product of any two distinct elements in the array.

## sample
5
1 2 3 4 5
20

</p>