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()))

mean = sum(A) / n

B = []
for i in A:
    B.append(abs(i - mean))
print(B.index(min(B)))

Solution (Python):
n = int(input())
a = [int(s) for s in input().split()]

average = sum(a) / n
for i in range(n):
    a[i] = abs(average - a[i])
print(a.index(min(a)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
x = sum(A) * 1.0 / N
ans = 0
m = 10000
for i in range(N):
  n = abs(x - A[i])
  if m > n:
    m = n
    ans = i
print(ans)

Solution (Python):
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

m = sum(A) / N

res = 10 ** 9
cost = 10 ** 9
for i, a in enumerate(A):
    if abs(a - m) < cost:
        res = i
        cost = abs(a - m)

print(res)

Solution (Python):

import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N = int(input())
    a = list(map(int, input().split()))

    avg = sum(a) / N
    min_abs = 10**9
    for i in range(N):
        min_abs = min(min_abs, abs(a[i] - avg))
    for i in range(N):
        if abs(a[i] - avg) == min_abs:
            print(i)
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ave = sum(a)/N
ans = -1
now = 10000000000
for i in range(N):
  if abs(a[i]-ave) < now:
    ans = i
    now = abs(a[i]-ave)
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ave = sum(a)/len(a)
dis = []
for i in range(n):
  dis.append(abs(a[i]-ave))
mi = min(dis)
for i in range(n):
  if abs(a[i]-ave) == mi:
    print(i)
    exit()

Solution (Python):
import statistics
n = int(input())
a = list(map(int,input().split()))
s = statistics.mean(a)
c = float("inf")
for i in range(n):
    if c!=min(abs(s-a[i]),c):
        c = abs(s-a[i])
        d = i
print(d)

Solution (Python):
import statistics
n = int(input())
a = list(map(int,input().split()))
s = statistics.mean(a)
c = float("inf")
for i in range(n):
    if c!=min(abs(s-a[i]),c):
        c = abs(s-a[i])
        d = i
print(d)

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

ave = 0
for i in range(N):
    ave += A[i]

ave = ave/N

ans = 0
m = 10**8
for i in range(N):
    tmp = A[N-1-i]
    res = abs(tmp-ave)
    if res<=m:
        m = res
        ans = N-1-i
print(ans)

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

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

Solution (Python):
a=int(input())
f = list(map(int,input().split()))
b=[]
ave=sum(f)/a

for i in f:
    diff=abs(i-ave)
    b.append(diff)
print(b.index(min(b)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
sa = sum(A)
ans, min_diff = N, sa
for i in range(N - 1, -1, -1):
    d = abs(A[i] * N - sa)
    if d <= min_diff:
        ans = i
        min_diff = d
print(ans)

Solution (Python):
import math
from statistics import mean

b=int(input())




f = list(map(int,input().split()))


mea = mean(f)
lis=[]

if mea in f :
    print(f.index(mea))
else:
    for i in range(len(f)):
        lis.append(abs(mea-f[i]))
    print(lis.index(min(lis)))

Solution (Python):

N = int(input())
a = [int(i) for i in input().split()]

avg = sum(a) / len(a)
diff = [abs(i - avg) for i in a]

print(diff.index(min(diff)))

Solution (Python):
n = int(input())
a = [int(s) for s in input().split()]
avg = sum(a) / len(a)

min_abs = 100
index = 0
for i in range(len(a)):
    if abs(avg - a[i]) < min_abs:
        min_abs = abs(avg - a[i])
        index = i
print(index)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
p = sum(a) / n
t = []
for i in a:
    t.append(abs(p-i))
p = min(t)
print(t.index(p))

Solution (Python):
n = int(input())
a = list(map(int, input().split(' ')))
avg = 0
for i in range(n):
    avg += a[i]
avg /= n
delta = 100
ans = -1
for i in range(n):
    d = abs(avg - a[i])
    if d < delta:
        ans = i
        delta = d
print(ans)

Solution (Python):
N=int(input())
*a,=map(int,input().split())

if N == 1:
  print(0)
  exit()

m = sum(a)

MIN=10**20
argmin=-1
for i in range(N):
  if MIN>abs(m-a[i]*N):
    MIN = abs(m-a[i]*N)
    argmin = i
print(argmin)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    a = list(map(int, readline().split()))
    S = sum(a)
    b = list(map(lambda x: abs(S - N * x), a))
    print(b.index(min(b)))


if __name__ == '__main__':
    main()

Solution (Python):

n=int(input())
l = list(map(int,input().split()))
heikin=sum(l)/n
tmp=float('inf')
ans=n-1
for i in range(n-1,-1,-1):
    if abs(l[i]-heikin) <= tmp:
        ans=i
        tmp=abs(l[i]-heikin)
print(ans)

Solution (Python):
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    sum_a = sum(a_list)
    min_val = 100
    min_index = 0

    for i, a in enumerate(a_list):
        d = abs(n * a - sum_a)
        if d < min_val:
            min_val = d
            min_index = i

    print(min_index)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    mean_a = sum(a_list) / n
    diff_list = [abs(a - mean_a) for a in a_list]
    min_a = min(diff_list)
    print(diff_list.index(min_a))


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys, math
from functools import lru_cache
import numpy as np
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    a = list(mi())
    mean = sum(a)/N

    m = min((abs(a[i]-mean), i) for i in range(N))
    print(m[1])

if __name__ == '__main__':
    main()

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

mean = sum(l)/n
x=10**9+7
y=-1
for i in l:
    if x > abs(i-mean):
        x = abs(i-mean)
        y = i

print(l.index(y))

Solution (Python):
N = int(input())
AA = map(int,input().split())
AAA = list(AA)
ans = sum(AAA)/N
ans1 = 0
avg = abs(AAA[0] - ans)
for i in range(N):
  if avg > abs(AAA[i]-ans):
    ans1 = i
    avg = abs(AAA[i]-ans)
    
print(ans1)

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

tot = sum(a)
ans = -1
dif = 10**6
for i,ai in enumerate(a):
    dif_i = abs(ai*n - tot)
    if(dif > dif_i):
        dif = dif_i
        ans = i
print(ans)

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

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

ans = 0
sw = float("Inf")
for i in range(n):
    if abs(ave-a[i]) < sw:
        ans = i
        sw = abs(ave-a[i])
        
print(ans)

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

li = [abs(L[i]-sum(L)/len(L)) for i in range(n)]

print(li.index(min(li)))

Solution (Python):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    m = sum(A) / n
    A = [abs(a - m) for a in A]
    print(A.index(min(A)))

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
o=list(map(int,input().split()))
a=sum(o)/n
dif=1000000000
ans=-1
for i,k in enumerate(o):
    if abs(a-k)<dif:
        dif=abs(a-k)
        ans=i
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
m=sum(a)/len(a)
tmp=10**3
ans=0
for i in range(n):
    if abs(a[i]-m)<tmp:
        ans=i
        tmp=abs(a[i]-m)
print(ans)

Solution (Python):
'''
Created on 2020/08/21

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  a=list(map(int,pin().split()))
  ave=sum(a)
  ans=0
  now=100*N
  for i in range(N):
    if abs(N*a[i]-ave)<now:
      now=abs(N*a[i]-ave)
      ans=i 
  print(ans)
  return 
main()

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N
B = [0]*N
for i in range(N):
  B[i] = abs(A[i]-ave)
m = min(B)
for i in range(N):
  if B[i] == m:
    print(i)
    exit()

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

sum = 0
for i in frames:
    sum += i

mean = sum/len(frames)

diff_lists = []
for j in frames:
    diff = j - mean
    diff_lists.append(abs(diff))

tmp_lists = diff_lists.copy()
tmp_lists.sort()
ans = diff_lists.index(tmp_lists[0])

print(ans)

Solution (Python):
N = int(input())

N_list = list(map(int,input().split()))

N_avg = sum(N_list)/N
N_avg_list=[]
for i in range(N):
  N_avg_list.append(abs(N_list[i]-N_avg))
  
print(N_avg_list.index(min(N_avg_list)))

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

ave = sum(a)/n
ans = -10
diff = 10**10

for i in range(n):
    diff1 = abs(ave - a[i])
    if diff1 < diff:
        diff = diff1
        ans = i

print(ans)

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

s = sum(A)
res = None
tmp = 10**18

for i in range(N):
    if abs(s - A[i] * N) < tmp:
        tmp = abs(s - A[i] * N)
        res = i

print(res)

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

s = sum(A)
res = None
tmp = 10**18

for i in range(N):
    if abs(s - A[i] * N) < tmp:
        tmp = abs(s - A[i] * N)
        res = i

print(res)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ave = sum(a) / n
diff = float('inf')
for i in range(n):
    if diff > abs(a[i]-ave):
        diff = abs(a[i]-ave)
        ans = i

print(ans)

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

Solution (Python):
import math
import numpy
import sys
readline = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))
    avgA = numpy.average(A)
    B = list(map(lambda x: abs(x - avgA) ,A))
    minB = min(B)

    print(B.index(minB))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ave = sum(a)/n
ans = abs(ave-a[0])
num = 0
for i in range(1,n):
    tmp = abs(ave-a[i])
    if tmp < ans:
        ans = tmp
        num = i
print(num)

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

d = INF
ans = 0
for i in range(N):
    diff = abs(A[i] - avg)
    if diff < d:
        d = diff
        ans = i
print(ans)

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

ans = 0
for i in range(1, n):
    if abs(a[ans] - a_ave) > abs(a[i] - a_ave):
        ans = i

print(ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
ave=sum(a)/N
deff=10**9
ans=0
for i in range(N):
  if abs(a[i]-ave)<deff:
    deff=abs(a[i]-ave)
    ans=i
print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = sum(a) / n
    c = [abs(b - a[i]) for i in range(n)]
    print(c.index(min(c)))


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
from decimal import Decimal

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ave = sum(A) / Decimal(N)
    min_diff = 100
    for i, a in enumerate(A):
        if abs(ave - a) < min_diff:
            min_diff = abs(ave - a)
            ans = i

    print(ans)


if __name__ == "__main__":
    main()

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

ave = sum(A)/len(A)
ans = []
for i in range(n):
    tmp = abs(A[i] - ave)
    ans.append(tmp)


print(ans.index(min(ans)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
import numpy
B = numpy.array(A)
b = numpy.average(A)
ans = 0
dif = abs(A[0] - b)
for i in range(1, N):
    a = abs(A[i] - b)
    if a < dif:
        dif = a
        ans = i
print(ans)

Solution (Python):
from statistics import mean
_ = input()
A = [int(i) for i in input().split()]
m = mean(A)

min_d = 100
index = 0
for i in range(len(A)):
  if abs(A[i] - m) < min_d:
    min_d = abs(A[i] - m)
    index = i
print(index)

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

r=sum(a)/n
m=10000
ans=0
for i in range(n):
    if m>abs(a[i]-r):
        m=abs(a[i]-r)
        ans=i
print(ans)

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

ave_a=sum(a)/len(a)
import numpy as np
a=np.array(a)
de_a=abs(a-ave_a)
print(np.argmin(de_a))

Solution (Python):
n = int(input())
alst = list(map(int, input().split()))
ans = 0
ave = sum(alst) / n
d = abs(ave - alst[0])

for i, num in enumerate(alst):
    d_tmp = abs(ave - num)
    if d_tmp < d:
        ans = i
        d = d_tmp
print(ans)

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

ave=sum(a)/n
d=1001001001001
ans=0

for i in range(n):
    if d > abs(a[i]-ave):
        d=min(d,abs(a[i]-ave))
        ans=i
    
print(ans)

Solution (Python):


from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ave = sum(a) / n
    ans = 0
    for i in range(n):
        ai = a[i]
        if abs(ai - ave) < abs(a[ans] - ave):
            ans = i
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

md=sum(a)/n
dist=float("inf")
ans=float("inf")
for i in range(n):
    if abs(a[i]-md)<dist:
        ans=i
        dist=abs(a[i]-md)
print(ans)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
avg = sum(l)/n
idx=0
mindiff=101
for i,j in enumerate(l):
  if abs(avg-j)<mindiff:
    mindiff = abs(avg-j)
    idx = i
print(idx)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
num = sum(a)/n
a = [abs(i-num) for i in a]
print(a.index(sorted(a)[0]))

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

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
m = sum(a)/ n
index = 0
for i in range(1,n):
  if abs(m-a[index])>abs(m-a[i]):
    index = i
print(index)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
aa = [i * n for i in a]
m = sum(a)
aaa = [abs(i - m) for i in aa]
mi = min(aaa)

for idx, elem in enumerate(aaa):
    if elem == mi:
        print(idx)
        exit()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
b = sum(a) / n
c = abs(a[0] - b)
d = 0

for i in range(1,n):
    if abs(a[i] - b) < c:
        c = abs(a[i] - b)
        d = i

print(d)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
s = sum(a)
m = inf
for i in range(n):
    if m > abs(s / n - a[i]):
        m = abs(s / n - a[i])
        idx = i
print(idx)

Solution (Python):
N = int(input())

a = list(map(int,input().split()))

avg = sum(a)/N

near_num = 101
res = 0

for i in range(N):
    if abs(a[i]-avg) < near_num:
        res = i
        near_num = abs(a[i]-avg)
print(res)

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

ave=sum(a)/n
min_v=10**9
for i in range(n-1,-1,-1):
  if abs(a[i]-ave)<=min_v:
    min_v=abs(a[i]-ave)
    ans=i

print(ans)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

median = sum(As)/N
lis = [(abs(a-median), i) for i, a in enumerate(As)]
lis.sort()
print(lis[0][1])

Solution (Python):

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

mean = sum(A)/N
mini = sum(A)
ans = 0

for i in range(len(A)):
    if abs(mean-A[i]) < mini:
        ans = i
        mini = abs(mean-A[i])

print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)/n
m=10**10
ans=0
for i in a:
  if m>abs(ave-i):
    m=abs(ave-i)
    ans=i
print(a.index(ans))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

median = sum(As)/N
lis = [(abs(a-median), i) for i, a in enumerate(As)]
lis.sort()
print(lis[0][1])

Solution (Python):
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  ave = sum(A)/N
  B = list(map(lambda x:abs(x-ave),A))
  for i in range(N):
    B[i] = [B[i],i]
  B.sort(key=lambda x:(x[0],x[1]))
  ans = B[0][1]
  return ans
print(solve())

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
INF = float("inf")
ave = sum(A)/N
MIN = INF

for i in range(N):
  if abs(A[i]-ave) < MIN:
    ans = i
    MIN = abs(A[i]-ave)
    
    
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ave = sum(A) / N
ave_A = [0]*N
output = 10000007
for i in range(N):
  ave_A[i] = abs(A[i] - ave)
for i in range(N):
  output = min(output, ave_A[i])
print(ave_A.index(output))

Solution (Python):
def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  avr = sum(a) / n
  b = []
  m = 100000
  for x in a:
    b.append(abs(x - avr))
    m = min(m, abs(x - avr))
  for i in range(len(b)):
    if b[i] == m:
      print(i)
      return
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
minimum=10**9
k=sum(a)
ans=0
for i in range(n):
  if abs(a[i]*n-k)<minimum:
    ans=i
    minimum=abs(a[i]*n-k)
print(ans)

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

mean = sum(a)/n
now = 0
sa = 10**10

for i,j in enumerate(a):
    if abs(mean-j) < sa:
        now = i
        sa = abs(mean-j)

print(now)

Solution (Python):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    avg = sum(A)/N
    mi = abs(A[0] - avg)
    idx = 0
    for i, a in enumerate(A[1:], start=1):
        if abs(a - avg) < mi:
            mi = abs(a - avg)
            idx = i
    print(idx)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
lst = list(map(int, input().split()))
m = sum(lst) / n
z = 10 ** 20
for i in range(n):
  a = abs(lst[i] - m)
  if a < z:
    z = a
    idx = i
print(idx)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ave_a = sum(a)/len(a)
diff = list(map(lambda x:abs(x-ave_a),a))
print(diff.index(min(diff)))

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

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

S=sum(A)
i=0
while i<N:
    A[i]*=N
    i+=1

now=float('inf')
i=0
while i<N:
    if abs(S-A[i])<now:
        now=abs(S-A[i])
        ans=i
    i+=1

print(ans)

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

ave = sum(a)/n
number = []
small = 10**3

for i in range(n):
    if abs(a[i] - ave) < small:
        number = []
        number.append(i)
        small = abs(a[i] - ave)

number.sort()

print(number[0])

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(_) for _ in stdin.readline().rstrip().split()]
avg = sum(a) / len(a)
ans_idx = 0
ans_f = 101
for i, f in enumerate(a):
    diff = abs(f-avg)
    if diff < ans_f:
        ans_f = diff
        ans_idx = i
print(ans_idx)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
me = sum(l)/n
ans = -1
now = 10**10
for i in range(n):
    if abs(me-l[i])<now:
        now = abs(me-l[i])
        ans = i
print(ans)

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

ans = 0
j = 101
for i in range(n):
    tmp = abs(a[i]-av)
    if j > tmp:
        j = tmp
        ans = i

print(ans)

Solution (Python):
n = int(input())
a_lis = list(map(int, input().split()))
ans = max(a_lis)
ans_a = n
a_avg = sum(a_lis)/len(a_lis)

for i, a in enumerate(a_lis):
    if abs(a - a_avg) < ans:
        ans = abs(a - a_avg)
        ans_a = i

print(ans_a)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
s=sum(a)
t=200
A=0
for i in range(N-1,-1,-1):
    d=abs(a[i]*N-s)
    if d<=t:
        t=d
        A=i
print(A)

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

total = sum(A)

diff = total
ans = -1
for index, a in enumerate(A):
    if diff > abs(total - N * a):
        ans = index
        diff = abs(total - N * a)

print (ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)/n
x=100
ans=-1
for i in range(n):
  if x>abs(ave-a[i]):
    x=abs(ave-a[i])
    ans=i
print(ans)

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

Solution (Python):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = []
    ave = sum(A)/N
    this = max(A)
    count = 0
    for i in A:
        ans.append(abs(ave-i))
    for j in range(N):
        if this > ans[j]:
            count = j
            this = ans[j]
    print(count)
resolve()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
a = LIST()

ave = sum(a)/N

b = [abs(x-ave) for x in a]

ans = b.index(min(b))
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
a = LIST()

ave = sum(a)/N

b = [[abs(x-ave), i] for i, x in enumerate(a)]

b.sort(key = lambda x: (x[0], x[1]))

print(b[0][1])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
mean = sum(a) / n
INF = 10**5
flg = INF
for i in range(n):
  if abs(mean - a[i]) < flg:
    idx = i
    flg = abs(mean - a[i])
print(idx)

Solution (Python):
n = int(input())
frame = list(map(int, input().split()))
avg = sum(frame) / n
ans= []
for d in frame:
    ans.append(abs(d-avg)) 
    
print(ans.index(min(ans)))

Solution (Python):
n = int(input())
a_l = list(map(int, input().split()))
import numpy as np
ave_a = np.mean(a_l)
a_l2 = [ (i, abs(j-ave_a)) for i,j in enumerate(a_l) ]
a_l3 = sorted(a_l2, key=lambda x: x[1])
print(a_l3[0][0])

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N = I()
A = IL()
M = sum(A)
B = [ (abs(A[i]*N-M),i) for i in range(N)]
B.sort()
print(B[0][1])

Solution (Python):
import numpy as np
n = int(input())
f = np.array(list(map(int, input().split())) )
print(np.where(abs(f - np.mean(f)) == min(abs(f - np.mean(f))))[0][0])

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

ave = sum(A) / len(A)

for i in range(N):
  A[i] = abs(A[i]-ave)

minA = min(A)

print(A.index(minA))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
t=sum(A)
for i in range(N):
  A[i]=abs(A[i]*N-t)
dif = min(A)
for i in range(N):
  if dif==A[i]:
    print(i)
    break