#K14331. Average of Even Numbers

    ID: 24111 Type: Default 1000ms 256MiB

Average of Even Numbers

Average of Even Numbers

You are given a list of integers. Your task is to filter out all the even numbers from the list and compute their average. If there are no even numbers in the list, simply output 0.

The average is defined as follows:

\(\text{average} = \frac{\sum_{i=1}^{k}{a_i}}{k}\)

where \(a_i\) represents the even numbers found in the list and \(k\) is the number of even numbers. If \(k = 0\), output 0.

Note: Input will be provided via standard input (stdin) and output should be written to standard output (stdout).

inputFormat

The first line of input contains a single integer \(n\), representing the number of elements in the list. The second line contains \(n\) space-separated integers.

outputFormat

Output the average of all even numbers in the list. If there are no even numbers, output 0. If the average is a whole number, print it as an integer; otherwise, print the floating point value.

## sample
5
1 2 3 4 5
3

</p>