Boring Number

Time limit: 1000 ms
Memory limit: 128 MB

You are given an array AA of NN integers. Find the index ii of an element such that the absolute difference between AiA_i and the arithmetic mean of all the NN integers is minimum. If the solution is not unique, find the smallest index ii.

Standard input

The first line contains a single integer NN.

The second line contains the NN elements of the array AA.

Standard output

Print the answer on the first line.

Constraints and notes

  • 1N1031 \leq N \leq 10^3
  • 1Ai1051 \leq A_i \leq 10^5

InputOutputExplanation
4
1 2 3 4
2

The arithmetic mean of the numbers is 2.52.5. The absolute difference between the mean and A2A_2 or A3A_3 is 0.50.5, but you should output the smallest index.

3
1 2 2
2

The artihmetic mean is 1.(6)1.(6), A2A_2 and A3A_3 have the minimum absolute difference of 0.(3)0.(3)

3
2 1 1
2

The artihmetic mean is 1.(3)1.(3), A2A_2 and A3A_3 have the minimum absolute difference of 0.(3)0.(3)

Authenticate to use the workspace

Log In
Sign Up
Forgot Password?
or connect with