atcoder#DWACON5THPRELIMSA. Thumbnail
Thumbnail
Score : points
Problem Statement
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure:
- Get an integer and integers as inputs. denotes the number of the frames of the video, and each denotes the representation of the -th frame of the video.
- Select -th frame whose representation is nearest to the average of all frame representations.
- If there are multiple such frames, select the frame with the smallest index.
Find the index of the frame he should select to generate a thumbnail.
Constraints
- All numbers given in input are integers
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
1 2 3
1
Since the average of frame representations is , Niwango-kun needs to select the index , whose representation is , that is, the nearest value to the average.
4
2 5 2 5
0
The average of frame representations is . In this case, every frame has the same distance from its representation to the average. Therefore, Niwango-kun should select index , the smallest index among them.