All problems

Dropping the Extreme Values

mediumPythonNumPyBoolean Indexing

A handheld meter at Northgate Water records a level every time an inspector presses the button, and a knock on the casing makes it write out something wild. Before a batch is filed, the department drops the obvious rubbish with one standard rule: a reading is thrown out when it lies further than two standard deviations from the batch average. The standard deviation is the usual measure of how spread out a batch is; take the population one, which is what NumPy gives you unless told otherwise. Both the average and the spread are measured over the batch exactly as it arrived, extreme readings included. Distance counts in either direction, and a reading landing exactly two standard deviations out is on the line and survives.

Task: Print the readings that survive the rule.

Input

The first line holds an integer n, the count of readings. Each of the next n lines holds one reading, a whole number.

Output

One line holding the surviving readings, separated by single spaces, in the order they were read, each as a plain integer. It is possible for every reading to survive.

Example:

Input:
6
10
11
9
12
10
100

Output:
10 11 9 12 10

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…