题目描述
Problem Description
Niwango, an employee of Dwango, has been tasked with implementing a feature to generate thumbnails from uploaded videos. The procedure for selecting a frame from the video to use as a thumbnail is as follows:
- Receive the total number of frames \( N \) in the video and an integer sequence \( a \) of length \( N \) representing each frame as a single integer.
- Each frame is numbered sequentially from the beginning as \( 0, 1, \ldots, N-1 \), and the integer representing frame number \( i \) is \( a_i \).
- The frame closest to the average value of \( a \) is chosen as the thumbnail.
- If there are multiple such frames, the one with the smallest frame number is chosen as the thumbnail.
Output the frame number selected as the thumbnail according to this procedure.
Input Format
The input is given from the standard input in the following format:
\( N \) \( a_{0} \) \( a_{1} \) \( \ldots \) \( a_{N-1} \)
Output Format
Output the answer.
Sample Input and Output
Sample Input #1
3
1 2 3
Sample Output #1
1
Sample Input #2
4
2 5 2 5
Sample Output #2
0
Notes/Hints
Constraints
- \( 1 \leq N \leq 100 \)
- \( 1 \leq a_i \leq 100 \)
- All numbers given as input are integers.
Sample Explanation 1
The average value of \( a \) is \( 2 \), so the frame number \( 1 \) closest to this value is selected.
Sample Explanation 2
The average value of \( a \) is \( 3.5 \), but the distance from the average is the same for all frames. Therefore, the frame number \( 0 \) with the smallest frame number is selected.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分