#K63182. Greatest Even and Smallest Odd Sum
Greatest Even and Smallest Odd Sum
Greatest Even and Smallest Odd Sum
You are given a list of integers. Your task is to compute the sum of the greatest even number and the smallest odd number in the list.
If there are no even numbers, treat the greatest even number as \(0\). Similarly, if there are no odd numbers, treat the smallest odd number as \(0\). In the case where the list is empty, the answer is \(0\).
Input is provided via standard input: the first line contains a single integer \(n\), representing the number of integers. The second line contains \(n\) space-separated integers. Your program should print the resulting sum to standard output.
inputFormat
The first line contains an integer (n) (the number of integers). The second line contains (n) space-separated integers. If (n = 0), the second line may be empty.
outputFormat
Print a single integer — the sum of the greatest even number and the smallest odd number as described.## sample
6
2 4 1 3 6 5
7