Windy weather 4
Piglet, while lying in the meadow, watched the blades of grass sway in the wind. He realized that the swaying was due to the wind and devised a method to measure the wind's strength using the grass blades. According to Piglet, the wind strength is defined as the height of the largest group of grass blades that share the same height. If there are multiple such groups, the wind strength is the height closest to the average of all distinct heights. If there is still a tie, the smallest height among them is chosen, as Piglet preferred calm weather.
Input
The first line contains a single integer n, representing the number of grass blades Piglet is observing. The second line contains n integers, separated by spaces, indicating the heights of the grass blades.
All input values are natural numbers not exceeding 100, since Piglet did not like counting much and had never encountered numbers greater than 100 in his life.
Output
Output a single number, which is the wind strength according to Piglet's definition.