You are given an array A of N integers. Find the index i of an element such that the absolute difference between Ai and the arithmetic mean of all the N integers is minimum. If the solution is not unique, find the smallest index i.
The first line contains a single integer N.
The second line contains the N elements of the array A.
Print the answer on the first line.
Input | Output | Explanation |
---|---|---|
4 1 2 3 4 | 2 | The arithmetic mean of the numbers is 2.5. The absolute difference between the mean and A2 or A3 is 0.5, but you should output the smallest index. |
3 1 2 2 | 2 | The artihmetic mean is 1.(6), A2 and A3 have the minimum absolute difference of 0.(3) |
3 2 1 1 | 2 | The artihmetic mean is 1.(3), A2 and A3 have the minimum absolute difference of 0.(3) |