#K49122. Filter Numbers Greater Than Average
Filter Numbers Greater Than Average
Filter Numbers Greater Than Average
You are given a list of integers. Your task is to compute the arithmetic average ( \left( \frac{1}{n}\sum_{i=1}^{n} a_i \right) ) of the list and then output all numbers that are strictly greater than this average. However, if the list contains less than 3 integers or more than 50 integers, you should output the string "invalid list".
Input will be provided from standard input, and output must be sent to standard output.
inputFormat
The first line of input contains an integer ( n ) representing the number of elements. The second line contains ( n ) space-separated integers.
outputFormat
If ( n ) is less than 3 or greater than 50, output the string "invalid list". Otherwise, output the integers that are strictly greater than the average (computed as ( \frac{1}{n}\sum_{i=1}^{n} a_i )) separated by single spaces.## sample
5
1 2 3 4 5
4 5