#C14797. Product of Numbers Greater Than 5

    ID: 44485 Type: Default 1000ms 256MiB

Product of Numbers Greater Than 5

Product of Numbers Greater Than 5

You are given a list of integers. Your task is to compute the product of all numbers in this list that are greater than 5. If there is no number greater than 5 in the list, output 1.

The product is defined as follows:

$$ \prod_{i=1}^{n}{a_i} = a_1 \times a_2 \times \dots \times a_n, $$

where the multiplication is only done for all integers ai such that ai > 5. If no such number exists, the answer defaults to 1.

Examples:

  • Input: [6, 7, 8] → Output: 336
  • Input: [2, 4, 6, 8, 10] → Output: 480
  • Input: [1, 2, 5] → Output: 1
  • Input: [] → Output: 1
  • Input: [10] → Output: 10
  • Input: [3] → Output: 1

inputFormat

The first line of the input contains an integer n ($n\ge0$), which is the number of integers in the list.

The second line contains n space-separated integers.

outputFormat

Output a single integer, the product of all numbers from the list that are greater than 5. If none, output 1.

## sample
3
6 7 8
336