#C12161. Product of Positive Integers

    ID: 41558 Type: Default 1000ms 256MiB

Product of Positive Integers

Product of Positive Integers

Given a list of integers, compute the product of all positive integers in the list. If there are no positive integers or the list is empty, output 1.

Note:

  • The product of no positive numbers is defined as 1.
  • Input is given via standard input and the result must be printed to standard output.

For example, if the input list is: [1, -2, 3, 0, -4], the product of the positive integers (1 and 3) is 3.

The mathematical interpretation is: if we denote the list as \(a_1, a_2, \ldots, a_n\), then the answer is \(\prod_{\substack{i=1 \\ a_i > 0}} a_i\) with the convention that the empty product is 1.

inputFormat

The input is read from standard input and consists of two lines:

  • The first line contains a single integer \(N\) indicating the number of integers.
  • The second line contains \(N\) space-separated integers \(a_1, a_2, \ldots, a_N\).

outputFormat

Print a single integer which is the product of all positive integers in the list. If there are no positive integers, print 1.

## sample
3
-1 -2 -3
1