#K14556. Product of Negative Numbers

    ID: 24160 Type: Default 1000ms 256MiB

Product of Negative Numbers

Product of Negative Numbers

Given an array of integers, compute the product of all the negative numbers. More formally, if the negative numbers in the array form a set \(S\), then compute the product

$$\prod_{x \in S} x$$

If there are no negative numbers in the array (or the array is empty), output 1.

inputFormat

The input consists of two lines. The first line contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated integers.

outputFormat

Output a single integer – the product of all negative numbers in the array. If there are no negative numbers, output 1.## sample

4
-1 2 -3 4
3