Problem:
 Score : 200 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 N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i -th frame of the video.  Select t -th frame whose representation a_t 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 t of the frame he should select to generate a thumbnail.      Constraints   1 \leq N \leq 100  1 \leq a_i \leq 100  All numbers given in input are integers         Input  Input is given from Standard Input in the following format:  N  a_{0}  a_{1}  ...  a_{N-1}       Output  Print the answer.        Sample Input 1  3
1 2 3      Sample Output 1  1  Since the average of frame representations is 2 , Niwango-kun needs to select the index 1 , whose representation is 2 , that is, the nearest value to the average.       Sample Input 2  4
2 5 2 5      Sample Output 2  0  The average of frame representations is 3.5 . In this case, every frame has the same distance from its representation to the average. Therefore, Niwango-kun should select index 0 , the smallest index among them.

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
avg = sum(A) / N
ansi = None
ansv = float('inf')
for i, a in enumerate(A):
  d = abs(a-avg)
  if d < ansv:
    ansi = i
    ansv = d
print(ansi)

Solution (Python):
N = int(input().strip())
A = list(map(int, input().strip().split()))

avgA = sum(A) / len(A)
diffA = [abs(a - avgA) for a in A]
mindiffA = min(diffA)
print(diffA.index(mindiffA))

Solution (Python):
N = int(input())
a = list(map(int,input().split(" ")))
b = [(0,0)]*N
k = sum(a) / N

for i in range(N):
    b[i] = (abs(a[i]-k),i)
b.sort()
print(b[0][1])

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ave = sum(a) / len(a)
c = []
for i in a:
    c.append(abs(i - ave))
print(c.index(min(c)))

Solution (Python):
N = int(input())
X = [int(a) for a in input().split()]

ave = sum(X)/N
ans = 0
mi = abs(X[0]-ave)
for i in range(N):
    if abs(X[i]-ave)<mi:
        ans = i
        mi = abs(X[i]-ave)
        
print(ans)

Solution (Python):
import numpy as np
n = int(input())
a = np.array(list(map(float, input().split(' '))))
a -= a.mean()
a = abs(a)
print(list(a).index(a.min()))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)/n
x=0
m=float('INF')
for i in range(n):
    if abs(a[i]-ave)<m:
        m=abs(a[i]-ave)
        x=i
print(x)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
S = sum(A)
min_res = S * N
ans = -1
for i, a in enumerate(A):
    if abs(N * a - S) < min_res:
        ans = i
        min_res = abs(N * a - S)
print(ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
h=sum(a)/N
b=[]
for i in range(N):
    b.append(abs(a[i]-h))
k=min(b)
for i in range(N):
    if(b[i]==k):
        print(i)
        break

Solution (Python):
import sys

input = sys.stdin.readline
n = int(input())
a_list = list(map(int, input().split()))

frame = 0
d = 1000
a_mean = sum(a_list)/n
for i in range(n):
    if abs(a_mean-a_list[i]) < d:
        frame = i
        d = abs(a_mean-a_list[i])
print(frame)

Solution (Python):

N = int(input())
a_list = list(map(int, input().split()))

m = sum(a_list) / N
res = 0
d = 2000
for i in range(N):
    if abs(a_list[i] - m) < d:
        res = i
        d = abs(a_list[i] - m)
print(res)

Solution (Python):
n = int(raw_input())
a = map(int, raw_input().split())
s = sum(a)
d = 10000000
ans = 0
for i, x in enumerate(a):
    t = abs(x * n - s)
    if d > t:
        d = t
        ans = i
print ans

Solution (Python):

import fractions
n = int(input())
a = list(map(fractions.Fraction, input().split()))
avg = sum(a) / n
_, i = min([ (abs(a[i] - avg), i) for i in range(n) ])
print(i)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
ave = sum(L)/N
tmp = 10**10
for i in range(N):
    if abs(ave - L[i]) < tmp:
        tmp = abs(ave - L[i])
        res = i
print(res)

Solution (Python):
N = int( input())
A = list( map( int, input().split()))
m = sum(A)/N
ans = 0
now = 1000
for i in range(N):
    if abs(m-A[i]) < now:
        ans = i
        now = abs(m-A[i])
print(ans)

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]

M = sum(A) / N
B = sorted([((A[_] - M)**2, _) for _ in range(N)])
print(B[0][1])

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
ave = 0
for e in arr:
    ave += e
ave /= n
res = 0
by = ave
for i, e in enumerate(arr):
    if abs(ave - e) < by:
        by = abs(ave - e)
        res = i

print(res)

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

ave = sum(a)/n

diff = 10**18
thum = -1
for i, ai in enumerate(a):
    if abs(ai-ave) < diff:
        diff = abs(ai-ave)
        thum = i

print(thum)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
MID=sum(A)/N

B=[(abs(A[i]-MID),i) for i in range(N)]
B.sort()

print(B[0][1])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

ave = sum(a) / n
ret = 0
hoge = 1e9

for i in range(n):
    tmp = abs(ave - a[i])
    if  tmp < hoge:
        ret = i
        hoge = tmp

print(ret)

Solution (Python):
N = int(input())
*A, = map(int, input().split())
S = sum(A)
v = 10**18; p = None
for i, a in enumerate(A):
    if abs(S - a*N) < abs(S - v*N):
        v = a
        p = i
print(p)

Solution (Python):
n = int(input())
nums = list(map(int, input().split()))
mean = sum(nums) / n
delta = float('inf')
ans = 0
for i, v in enumerate(nums):
  if abs(mean - v) < delta:
    ans = i
    delta = abs(mean - v)

print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x=sum(a)/n
b=[abs(a[i]-x) for i in range(n)]
mi=min(b)
for i in range(n):
    if b[i]==mi:
        print(i)
        break

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
av = sum(A)/N

choose = 0
dist = abs(A[0] - av)
for i in range(1, N):
    if abs(A[i]-av) < dist:
        choose = i
        dist = abs(A[i]-av)
print(choose)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N

ans = min_d = 10**10
for i,a in enumerate(A):
    d = abs(ave - a)
    if d < min_d:
        min_d = d
        ans = i
print(ans)

Solution (Python):
n = int(input())
aaa = list(map(int, input().split()))
ave = sum(aaa) / n
bbb = [(abs(a - ave), i) for i, a in enumerate(aaa)]
bbb.sort()
print(bbb[0][1])

Solution (Python):
n=int(input())
a = list(map(int, input().split()))
m = sum(a)/n

min_i = 0
min_v = float('inf')

for i,v in enumerate(a):
    if abs(v-m) < min_v:
        min_i = i
        min_v = abs(v-m)
print(min_i)

Solution (Python):
n = int(input())
a = [int(x) for x in input().strip().split()]
pos = -1
m = 10000
avg = sum(a) / n
for i in range(n):
    if abs(a[i]-avg) < m:
        pos = i
        m = abs(a[i]-avg)
print(pos)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))

b = sum(a)/n
for i in range(n):
    a[i] = abs(a[i]-b)

k = a.index(min(a))
print(k)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = list(map(int, input().split()))
avg = sum(As) / N

dist = 1e9
for i, a in enumerate(As):
    d = abs(a - avg)
    if d < dist:
        dist = d
        ans = i
print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    av = 1.0 * sum(a) / len(a)
    m = inf
    mi = -1
    for i in range(n):
        c = a[i]
        t = abs(c-av)
        if m > t + eps:
            m = t
            mi = i

    return mi


print(main())