#K81497. Filter Above Average
Filter Above Average
Filter Above Average
You are given a list of integers. Your task is to filter out and print only those numbers which are greater than the average of all the numbers in the list.
If the list is empty or contains only one element, print an empty line. The order of the numbers in the output should be the same as in the input.
For example, for the input list [1, 2, 3, 4, 5], the average is 3. The numbers greater than 3 are 4 and 5, so the output should be 4 5
.
inputFormat
The input is read from stdin
and formatted as follows:
- The first line contains an integer
n
, representing the number of elements in the list. - The second line contains
n
space-separated integers.
outputFormat
Print to stdout
a single line containing all the integers from the input that are greater than the average, separated by a space. If no number is greater than the average, print an empty line.
5
1 2 3 4 5
4 5