#C6945. Product of Array (Taco Subset Problem)

    ID: 50761 Type: Default 1000ms 256MiB

Product of Array (Taco Subset Problem)

Product of Array (Taco Subset Problem)

You are given an array of integers. Your task is to compute the product of all the elements in the array. However, if any element in the array is zero, you should immediately output 0.

Formally, if the array is represented as \(a = [a_1, a_2, \dots, a_n]\), then the answer is defined as:

\[ P = \begin{cases} 0, & \text{if any } a_i = 0,\\[6pt] \prod_{i=1}^{n} a_i, & \text{otherwise.} \end{cases} \]

Note: If the array is empty, the product is defined as 1.

inputFormat

The input is provided via standard input (stdin) and has the following format:

  • The first line contains an integer \(n\) representing the number of elements in the array.
  • If \(n > 0\), the second line contains \(n\) integers separated by spaces.

If \(n=0\), the array is empty.

outputFormat

Output a single number, which is the product of all the elements in the array, following the rule that if any element is zero, output 0 immediately. The result should be printed to standard output (stdout).

## sample
4
1 2 3 4
24