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()))
avr=sum(a)/len(a)
l=[abs(avr-i) for i in a]
print(l.index(min(l)))

Solution (Python):



s = input()
w = input().split()
sum = 0
for i in range(int(s)):
    sum += int(w[i])
average = sum / int(s)
limit = 100
index = 0
for i in range(int(s)):
    if abs(int(w[i]) - average) < limit:
        limit = abs(int(w[i]) - average)
        index = i
print(index)

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

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

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

NA = sum(A)
mv = float('inf')
mi = -1

for i in xrange(N):
    v = abs(NA - A[i] * N)
    if v < mv:
        mv = v
        mi = i

print mi

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

av = sum(A) / N

min_dist = 9999
min_idx = 0

for i in range(N):
  if min_dist > abs(A[i] - av):
    min_dist = abs(A[i] - av)
    min_idx = i
    
print(min_idx)

Solution (Python):
n=int(input())
s=input().split()
l=[int(s[i]) for i in range(n)]
su=sum(l)
best=10000000000000000
res=0
for i in range(n):
  if(abs(su-n*l[i])<best):
    best=abs(su-n*l[i])
    res=i
print(res)

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

a = list(map(lambda x: int(abs(N*x-sum(a))), a))

print(a.index(min(a)))

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
m,x = sum(a),float("inf")
for i in range(n):
	if x>abs(m-n*a[i]): x,ans = abs(m-n*a[i]),i
print(ans)

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

md = sum(a)/n

ans = 0
m = float('inf')
for i in range(n):
    if abs(a[i]-md) < m:
        ans = i
        m = abs(a[i]-md)
print(ans)

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

avg = sum(a)/len(a)

m = 10000000000000
ans = 0
for i , val in enumerate(a):
    if abs(val - avg) < m:
        m = abs(val-avg)
        ans = i
print(ans)

Solution (Python):
def a_thumbnail(N, A):
    ave_x_n = sum(A)
    a = [abs(i * N - ave_x_n) for i in A]  
    ans = a.index(min(a))
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(a_thumbnail(N, A))

Solution (Python):


N = int(input())
ai = [int(_) for _ in input().split()]

d = sum(ai)
ave = d / N

i = 0
ret = None
for i in range(N):
    a = ai[i]
    if(abs(a - ave) < d):
        d = abs(a - ave)
        ret = i

print(ret)

Solution (Python):
import math
n = int(raw_input())
a =  raw_input().split()
a = map(int, a)
ave = float(sum(a))/n
dif = 10000
count  = 0
ans = 0
for x in a:
    s = abs(x-ave)
    if s < dif:
        dif = s
        ans = count
    count += 1
  
print("%d" % ans)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
Mean = sum(a)/N
a_norm = [a[i] - Mean for i in range(N)]
a_norm_abs = list(map(abs,a_norm))
print(a_norm_abs.index(min(a_norm_abs)))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
M = (sum(A))/N
t = 101
for e in A:
    t = min(t,abs(e-M))

for k in range(N):
    if abs(A[k]-M) == t:
        print(k)
        exit(0)

Solution (Python):
N = int(input())
an = [int(i) for i in input().split()]
s  = sum(an)
h = s/N
ans = -1
m = float('inf')
for i in range(N-1,-1,-1):
    t = abs(h-an[i])
    if m >= t:
        m = t
        ans = i
print(ans)

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

ans,m=0,1e22
for i,j in enumerate(a):
  if abs(j-avg)<m:
    ans=i
    m=abs(j-avg)

print(ans)

Solution (Python):
n = int(input())
*a, = map(int, input().split())
s = sum(a)/n
ans = -1
mind = 101
for i in range(n):
    t = a[i]
    if abs(t-s) < mind:
        mind = abs(t-s)
        ans = i
print(ans)

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
a = map(int, raw_input().split())

S = sum(a)

ans = 0
diff = INF

for i in range(N):
    if diff > abs(S - a[i] * N):
        diff = abs(S - a[i] * N)
        ans = i

print ans

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

ttl = sum(a)

ans = 0
for i, aa in enumerate(a):
    if abs(ttl - a[i] * n) < abs(ttl - a[ans] * n):
        ans = i
print(ans)

Solution (Python):
import numpy as np

_ = int(input())
a = np.array(list(map(int, input().split())))
idx = np.argmin(np.abs(a - a.mean()))
print(idx)

Solution (Python):
n=int(input())
tmp=list(map(int,input().split()))
a=[]
ave=0
for i in range(n):
    ave+=tmp[i]
    a.append([i,tmp[i]])

ave=ave/n
a.sort(key=lambda x:(abs(ave-x[1]),x[0]))

print(a[0][0])

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

ma = sum(a) / len(a)

def d(i):
    return abs(a[i] - ma)

best = 0
for i in range(len(a)):
    if d(i) < d(best):
        best = i

print(best)

Solution (Python):
import numpy as np

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

mean_a = np.mean(a)
ans = []

for i in range(N):
    ans.append(abs(a[i] - mean_a))

print(np.argmin(ans))

Solution (Python):
import numpy as np
N = input()
a = [int(i) for i in input().split()]
ans = np.argmin(np.abs(a - np.mean(a)))
print(ans)

Solution (Python):
n = int(input())
a = [int(s) for s in input().split()]
avg = sum(a) / len(a)
lengs = [abs(v - avg) for v in a]
minleng = min(lengs)
print(lengs.index(minleng))

Solution (Python):
n = int(input());
mylist = list(map(int, input().split()));
sum = 0;
for k in mylist:
	sum += k;
sum /= len(mylist);
maxi = 0;
for i in range(len(mylist)):
	if (abs(mylist[maxi] - sum) > abs(mylist[i] - sum)):
		maxi = i;
print(maxi);

Solution (Python):
import numpy as np

n = int(input())
a = list(map(int,input().split()))
median = np.average(a)
idx = np.abs(np.asarray(a) - median).argmin()

ans = 0
for i in range(n):
    if a[i] == a[idx]:
        ans = i
        break
print(ans)

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

Solution (Python):
n = int(input())
num = tuple(map(int,input().split()))
avr = sum(num)/n
pos = 0
d = 9999999999
for i in range(n):
    if abs(avr - num[i]) < d:
        d = abs(avr - num[i])
        pos = i
print(pos)

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

sum_a = sum(a)
mean_a = sum_a / N

for i in range(N):
    a[i] = abs(a[i] - mean_a)
thum = min(a)

for i in range(N):
    if a[i] == thum:
        print(i)
        break

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

average = sum(a) / len(a)

min_diff = abs(a[0] - average)
ans = 0
for i, x in enumerate(a):
    if min_diff > abs(x - average):
        min_diff = abs(x - average)
        ans = i

print(ans)

Solution (Python):
x = int(input())
a = input().split()
list(map(int, a))
c = 100
d = 100
cange = 0
f = 0
for i in range(x):
  f += int(a[i]) 
  
b = f / x

for i in range(x):
    if abs(b - int(a[i])) < d :
        d = abs(b - int(a[i]))
        e = i
        cange = 1
if cange:
	print(e)
else:
    print(0)

Solution (Python):

import numpy as np


def main():
    N = input()
    a = np.array([int(ele) for ele in raw_input().split()])
    avg = sum(a) / float(N)
    a = a - np.array([avg] * N)
    a = map(abs, list(a))
    print(a.index(min(a)))


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
sum = 0
for i in a:
    sum += i
mean = sum / len(a)
min = 100
for i in range(len(a)):
    if min == abs(mean - a[i]):
        continue
    if min > abs(mean - a[i]):
        min = abs(mean - a[i])
        ans = i
print(ans)

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

def minus(m):
    return abs(m-sum(a)/n)

a2 = list(map(minus,a))

print(a2.index(min(a2)))

Solution (Python):
N, = [int(x) for x in input().strip().split(" ")]
As = [int(x) for x in input().strip().split(" ")]

ave = float(sum(As))/N
diss = [abs(ave-a) for a in As]
minn = sorted(diss)[0]
for i, x in enumerate(diss):
    if x == minn:
        aaa = i
        break
print(aaa)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
M = sum(A) / len(A)
D = max(A)
I = 0

for i, a in enumerate(A):
    if D > abs(a - M):
        D = abs(a - M)
        I = i

print(I)

Solution (Python):
def main():
    n = input()
    data = input().split()
    data = list(map(lambda x: int(x), data))

    mid_val = calculate_mean(data)

    if int(n) < 1 or 101 < int(n):
        return -1

    current_pos = -1
    current_distance = 101

    if int(n) == len(data):
        for key, value in enumerate(data):
            if int(value) < 1 or 101 < int(value):
                return -1
            new_distance = abs(mid_val - value)
            if current_distance > new_distance:
                current_pos = key
                current_distance = new_distance
        return current_pos


def calculate_mean(data):
    s = sum(data)
    N = len(data)
    mean =s/N

    return mean

r = main()
print(r)

Solution (Python):

import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    
    import numpy
    def dprint(*args, **kwargs):
        
        
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') 
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') 
    atexit.register(lambda :sys.stdout.close())     
    
N, = getIntList()

za  = getIntList()
tot = sum(za)
ti = 0
td = 10000000
for i in range(N ):
    x = za[i]
    t = abs(x*N - tot)
    if t<td:
        td = t
        ti = i
print(ti)

Solution (Python):
from statistics import mean

N = int(input())
a = [int(i) for i in input().split()]
m = mean(a)
d = 100
r = 0

for i, v in enumerate(a):
    if abs(m - v) < d:
        d = abs(m - v)
        r = i

print(r)

Solution (Python):



import sys

input = raw_input()
N = int(input)
aVec = raw_input().split(" ")
a = []

for i in aVec:
    a.append(float(i))



mean = sum(a) / N


near_mean = []

for i in a:
    near_mean.append(abs(i - mean))



print near_mean.index(min(near_mean))

Solution (Python):
from sys import stdin

a = []
sum = 0

n = int(stdin.readline().rstrip())
a = [int(y) for y in stdin.readline().rstrip().split()]

for i in range(n) :
    sum = sum + a[i]

ave = sum / n
tmp = abs(a[0] - ave)
ans = 0

for i in range(n) :
    if (abs(a[i] - ave) < tmp ) and ( a[ans] is not a[i]):
        ans = i
        tmp = abs(a[i] - ave)
        
print(ans)

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

ans=0
diff=10**9
for idx, x in enumerate(A):
	if diff>abs(x-ave):
		ans=idx
		diff=abs(x-ave)

print ans

Solution (Python):
n = int(input())
list = list(map(int,input().split()))
flist = []
avr = sum(list)/n

for i in range(n):
    flist.append(max(list[i], avr) - min(list[i], avr))

d = flist.count(min(flist))

if d == n:
    print("0")
else:
    index = flist.index(min(flist))
    print(index)

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

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


ave = sum(a)/n
diff = [abs(ave - x) for x in a]


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

Solution (Python):
import numpy as np
N = int(input())
a = list(map(int, input().split()))

avg = 0
for i in range(N):
    avg += a[i]
avg /= N

idx = np.abs(np.asarray(a)-avg).argmin()
print(idx)

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

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
b=sum(a)/n
c=0
d=abs(a[0]-b)
for i in range(n):
 if(abs(a[i]-b)<d):
  c=i
  d=abs(a[i]-b)
 else:
  continue
print(c)

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

avg=sum(a)/n
b=[abs(int(j)-avg) for j in a]


print(b.index(min(b)))

Solution (Python):
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
k = sum(a)
k = k/n
ans = n-1
kyo = 100000000000000000
for i in range(n-1,-1,-1):
  if kyo >= abs(a[i]-k):
    kyo = abs(a[i]-k)
    ans = i
print(ans)

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

l = input().split(" ")
int_l = list(map(int, l))

avg_l = sum(int_l) / N

diff_l =[]
for i in range(N):
  diff_l.append(abs(avg_l - int_l[i]))

answer = diff_l.index(min(diff_l))
print(answer)

Solution (Python):
import sys
N = int(sys.stdin.readline().rstrip())
a = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
  print(0)
else:
  print(d.index(min(d)))

Solution (Python):
import numpy as np

n = int(input())
a = str(input())
array = [int(s) for s in a.split()]
sum = 0
difference = 0
index = 0

avarage = np.average(array)

for i, a in enumerate(array):
    tmp_diff = abs(a-avarage)
    if i == 0:
        difference = tmp_diff
        index = 0
    else:
        if difference > tmp_diff:
            difference = tmp_diff
            index = i

print(index)

Solution (Python):
n = int(input())
l = [int(i) for i in input().split()]
av, ans = sum(l) / n, 0
d = abs(l[0] - av)
for i in range(n):
  t = abs(l[i] - av)
  if d > t:
    d, ans = t, i
print(ans)

Solution (Python):
a=int(input())
b = [int(i) for i in input().split()]


c={}
for i in range(a):
	c.update({i:abs(sum(b)/a-b[i])})

c=sorted(c.items(), key=lambda x: x[1])

print(c[0][0])

Solution (Python):
n =int( input() )
a = input().split()
a_list = []
summ = 0
for ai in a:
  summ += int(ai) 
  a_list.append(int(ai))
ave = summ/n
result = 0
min_dis = abs(a_list[0] - ave)
for i,ai in enumerate(a_list):
  dis = abs(ai - ave)
  if dis > min_dis:
    pass
  elif dis == min_dis:
    result = min(result,i)
  else:
    min_dis = dis
    result = i
print(result)

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

keys = [i for i in range(N)]


ave = 0
newa = []
for j in range(N):
    ave =  ave + a[j]
    newa.append(a[j]*N)
      
adict = dict(zip(keys, newa))
    
mat =[]
for i in range(N):
    mat.append(abs(newa[i]-ave))
    

amin = min(mat)


keys = [k for k, v in adict.items() if abs(v-ave) == amin]


print(min(keys))

Solution (Python):
from statistics import mean
import math
n = int(input())
a = list(map(int, input().split()))

m = mean(a)
Min = math.fabs(a[0]-m)
ret = []

for i in range(1, len(a)):
    if math.fabs(a[i]-m) < Min:
        Min = math.fabs(a[i]-m)
        ret.append(i)


if len(ret) > 0:
    print(ret[-1])
else:
    print(0)

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

num = list(map(int, input().split()))
ave = sum(num) / n

diff = None
for i, l in enumerate(num):
    if diff is None or abs(l - ave) < diff:
        diff = abs(l - ave)
        ans = i

print(ans)

Solution (Python):
n = input()
l = map(float,raw_input().split())
av = sum(l)/n
diff = abs(av-l[0])
index = 0
for i in xrange(1,n):
    if diff > abs(av-l[i]):
        index = i
        diff = abs(av-l[i])
print index

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

a=list(map(int,input().split()))
suma=0
for i in range(N):
  suma+=a[i]
meana=suma/N

tikai=101
for i in range(N):
  if abs(meana-a[i])<tikai:
    tikai=abs(meana-a[i])
    answer=i
print(answer)

Solution (Python):
import numpy as np

N = input()

A = input().strip().split(' ')
A=[int(x) for x in A]
A_ary=np.array(A)

mu=A_ary.mean()
ans=np.argmin(abs(A_ary-mu))
print(ans)

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]
means = sum(a)/N
res = 0

for i, x in enumerate(a):
    if abs(means - x) < abs(means - a[res]):
        res = i

print(res)

Solution (Python):
import sys
N = float(input())
a = list(map(int, input().split()))
sum = 0.0
avg = 0.0

for i in a:
    sum += i



avg = sum / N

result = sys.maxsize
answer = 0
for i in a:
    if result > abs(i - avg):
        result = abs(i - avg)
        answer = a.index(i)

print(answer)

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

s = sum(N)/P
minfr=9999
ans = 0

for i ,n in enumerate(N):
    minfr = min(minfr,abs(n-s))
    
    if minfr == abs(n-s):
        ans = i
    
print(abs(ans-(P-1)))

Solution (Python):
import numpy as np
n=int(input())
a=list(map(int,input().split()))
dis=np.abs(a-np.mean(a))
ind=np.argmin(dis)
print(np.min(ind))

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
n= input()
n = int(n)
a = input()
b = a.split()
c=[]
for i in range(n) :
    c.append(int(b[i]))
m = mean(c)
for i in range(n) :
    if c[0] != c[i]: break
    if i == n-1:
        print(0)
        sys.exit()
for i in range(n) :
    c[i] = c[i] - m
    c[i] = abs(c[i])
f = min(c)
print(c.index(f))

Solution (Python):
import numpy as np
N = int(input())
a = list(map(int, input().split()))

a = np.array(a)
thumbnail = np.mean(a)

print(abs(a-thumbnail).argmin())

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
mean = sum(A)/N
X = [abs(a-mean) for a in A]
x = min(X)
print(X.index(x))

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

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ave = sum(a)/n
m = float('inf')
for i in a:
    m = min(m,abs(ave-i))

for k,i in enumerate(a):
    if abs(abs(i-ave)-m) <= 10**(-6):
        print(k)
        exit()

Solution (Python):
import statistics


def main():
    input()
    a = list(map(lambda x: int(x), input().split()))
    average = statistics.mean(a)
    b = list(map(lambda x: abs(x - average), a))
    print(b.index(min(b)))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().strip().split()))
s = 0
for i in range(n):
	s += a[i]
mn = abs(a[0] * n - s)
ans = 0
for i in range(1, n):
	if (abs(a[i] * n - s) < mn):
		mn = abs(a[i] * n - s)
		ans = i
print(ans)

Solution (Python):
import numpy as np
N = int(input())
list = list(map(int,input().split()))
mean = np.mean(list)


minabs = 1000
min = 0
for i,data in enumerate(list):
    if abs(data - mean) < minabs:
        minabs = abs(data - mean)
        min = i

print(min)

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

Solution (Python):
from sys import stdin
from statistics import mean, median,variance,stdev
import numpy as np

def main():
    N = int(input())
    A = list(map(int, stdin.readline().rstrip().split()))
    m = mean(A)

    A = np.array(A)
    A = np.abs(A -m)

    print(np.argmin(A))

input = lambda: stdin.readline()
main()

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

average = sum(a)/len(a)

lst = []

for i in a:
    lst.append(abs(i-average))

print(lst.index(min(lst)))

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

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

ave=sum(a)/len(a)
k=abs(ave-a[0])
m=[]
for i in range(N):
    if abs(ave-a[i])<=k:
        k=abs(ave-a[i])
        
for i in range(N):
    if abs(ave-a[i])==k:
        print(i)
        break

Solution (Python):
int(input().strip())
a_s = list(map(int,input().strip().split()))
a_mean = sum(a_s)/len(a_s)
min_div_a = 0
answer = 0
for i,a in enumerate(a_s):
    if i==0 or min_div_a > abs(a_mean-a):
        min_div_a = abs(a_mean-a)
        answer = i
print(answer)

Solution (Python):
import numpy as np

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

mean = np.mean(a)

idx = np.abs(np.asarray(a) - mean).argmin()

print(idx)

Solution (Python):
n = int(input())
frame_list = list(map(int,input().split()))
frame_mean = sum(frame_list)/len(frame_list)
outcome = 200
count = 0

for i in range(n):
    if abs(frame_mean - frame_list[i]) < outcome:
        outcome = abs(frame_mean - frame_list[i])
        count = i

print(count)

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

ac = 0
ad = 999
mean = sum(aList) / len(aList)
for i in range(N):
    iad = abs(aList[i] - mean)
    if iad == 0:
        ac = i
        break
    elif iad < ad:
        ad = iad
        ac = i
    else:
        continue
print(ac)

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

ave=sum(a)/N
b=list(map(lambda x: abs(ave-x),a))
ans=min(b)

for i in range(N):
    if b[i]==ans:
        print(i)
        break

Solution (Python):
n = int(input())
num_list = list(map(int, input().split()))
sum_ = 0
for i in num_list:
    sum_ += i
mean = sum_ / n
min_ = 1000000000000000
for i in range(n):
    if abs(mean - num_list[i]) < min_:
        min_ = abs(mean - num_list[i])
        thumbnail = i
print(thumbnail)

Solution (Python):
import numpy as np
N = int(input())

a_arr = input().split()
tmp = []
for ele in a_arr:
    tmp.append(int(ele))
arr = np.array(tmp)
avg = np.mean(arr)
evaluate_arr = np.abs(arr - avg)
evaluate_pos = np.argmin(evaluate_arr)
print(evaluate_pos)

Solution (Python):

import statistics

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

def argmin(z):
    min_idx = 0
    min_val = 10000
    for k, v in enumerate(z):
        if min_val > v:
            min_idx = k
            min_val = v
    return min_idx, min_val

m = statistics.mean(a)
z = [abs(b - m) for b in a]

k, v = argmin(z)
print(k)

Solution (Python):
a=input()
a=input().split()
a=[int(i) for i in a]
avg =sum(a)/len(a)
a=[abs(i -avg) for i in a]
print(a.index(min(a)))

Solution (Python):
N = int(input())
I= list(map(int, input().split()))
NI = sum(I)/N
for i in range(N):
    I[i]=abs(I[i]-NI)
minI=min(I)
print(I.index(minI))

Solution (Python):
n=int(input())
a=input().split()
a=list(map(int,a))
mean=sum(a)/n
for i in range(n):
    a[i]=abs(a[i]-mean)
k=a[0]
j=0
for i in range(n):
    if  a[i]<k:
        k=a[i]
        j=i
print(j)

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
s=sum(a)
l=len(a)
x=s/l
z=100
for cnt,i in enumerate(a):
    y=abs(i-x)
    if y<z:
        ans=cnt
        z=y
print(ans)

Solution (Python):
import numpy as np
n=int(input())
nums=np.array(list(map(int,input().split())))
ave=np.average(nums)
print(np.argmin(np.abs(nums-ave)))

Solution (Python):
def 解():
    iN = int(input())
    aA = [int(_) for _ in input().split()]

    iM = sum(aA) / iN

    d = {}
    for i,a in enumerate(aA):
        d[i] = [a, abs(a - iM)]
    print(sorted(d.items(),key=lambda x:x[1][1])[0][0])
解()

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

min = abs(avg-max(a))+1
index=0
for i in range(len(a)):
    x=abs(a[i]-avg)
    if x < min:
        min = x
        index=i
print(index)

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)
print(a.index(min(a)))

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

Solution (Python):


import numpy as np
from sys import stdin

def load():
    n = stdin.readline()
    data = [int(x) for x in stdin.readline().split()]
    return (n,data)

def calc(n, data):
    d = np.asarray(data)
    m = d.mean()
    diff = np.abs(d - m)
    return diff.argmin()

n, data = load()
print(calc(n, data))

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

avg = sum(A) / N

ans = 0
cur = float('inf')
for i, a in enumerate(A):
    d = abs(avg - a)
    if cur > d:
        cur = d
        ans = i
print(ans)

Solution (Python):

if __name__ == "__main__":
    n = int(input())
    a = list(map(float, input().split()))

    mean = sum(a) / n

    dist = [0. for _ in range(n)]
    for i in range(n):
        dist[i] = abs(a[i] - mean)

    print(dist.index(min(dist)))

Solution (Python):
import sys

N = int(sys.stdin.readline())

A = map(int, sys.stdin.readline().strip().split(" "))

avg = 1. * sum(A) / N

near = 9999999
idx = -1
for i, a in enumerate(A):
    if near > abs(a-avg):
        near = abs(a-avg)
        idx = i

print(idx)

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

import numpy as np
mean = np.mean(a)
lst = []
for i in range(N):
  lst.append(np.abs(a[i]-mean))

min_val = np.min(lst)
for i in range(N):
  if lst[i] == min_val:
    print(i)
    break

Solution (Python):
import sys

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

ave = sum(a)/N

mini = float("inf")
ans = 0
for i,_a in enumerate(a):
	d = ave - _a
	d = abs(d)
	if d == 0:
		print(i)
		sys.exit()
	if mini > d:
		mini = d
		ans = i
print(ans)

Solution (Python):
from statistics import mean

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


avg = mean(a_list)
a_list2 = [abs(a - avg) for a in a_list]

print(str(a_list2.index(min(a_list2))))

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

mean = sum(a) / N
mini = (0, abs(a[0] - mean))
for i, ai in enumerate(a):
    if abs(ai - mean) < mini[1]:
        mini = (i, abs(ai - mean))
print(mini[0])

Solution (Python):


n = int(input())

a_arr = [a for a in map(int, input().split())]

a_ave = sum(a_arr)/n

min_frame_num = 0
for i in range(len(a_arr)):
    if i==0:
        min_frame_num = 0
        min_frame = abs(a_ave-a_arr[i])
    if min_frame > abs(a_ave-a_arr[i]):
        min_frame_num = i
        min_frame = abs(a_ave-a_arr[i])


print(min_frame_num)

Solution (Python):
N = input()

buf = input()

array = buf.split()

array_int = [int(ele) for ele in array]

sum_array = sum(array_int)
mean = float(sum_array) / int(N)

diff = [ float(abs(x-mean)) for x in array_int]


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

Solution (Python):
from sys import stdin
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
from statistics import mean
data_mean=mean(data)
def calc_(n):
    return abs(n-data_mean)
 
data2 = list(map(calc_, data))
data3=list(data2)
result=data3.index(min(data3))
print(result)

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





ave = sum(a)/len(a)

least_dif = 99999
ans = 0
for i, num in enumerate(a):
    dif = abs(num - ave)
    if dif < least_dif:
        least_dif = dif
        ans = i

print(ans)

Solution (Python):

array = list(map(int, input().strip().split(' ')))

N = array[0]

array1 = list(map(int, input().strip().split(' ')))

kazu = len(array1)

ans = 0

for i in range(N):

    ans = ans + array1[i]

heikin = ans / N

min_ans = 999
ans2 = 0

for i in  range(N):

    test = abs(array1[i] - heikin)
    

    if test < min_ans:

        min_ans = test
        ans2 = i

print(ans2)

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

su = sum(a) / n
mi = 1000
ans = 1000

for i, aa in enumerate(a):
	tmp = abs(aa - su)
	if tmp < mi:
		mi = tmp
		ans = i
		
print(ans)

Solution (Python):

import numpy as np

def main():
	n = int(input())
	a = list(map(int, input().split()))
	m = np.mean(a)
	r = 0
	
	for i in range(n):
		if ((a[i]-m)**2 < (a[r]-m)**2):
			r = i
	print(r)
	
main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
import numpy as np
av = np.mean(a)
nor = a - av
pos = [abs(i) for i in nor]
min = np.min(pos)
print(pos.index(min))

Solution (Python):
input()
lst = list(map(int,input().split()))
avg = sum(lst)/len(lst)
mn = abs(avg-lst[0])
mnn=0
for i in lst:
    if abs(avg-i)<mn:
        mnn=lst.index(i)
        mn = abs(i-avg)
print(mnn)

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

mean = sum(A) / N

err = abs(A[0]-mean)
ans = 0
for i, a in enumerate(A):
    
    if abs(a - mean) < err:
        
        err = abs(a - mean)
        ans = i

print(ans)

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

ave = sum(a) / N

min = abs(a[0] - ave)
min_num = 0


for i in range(1, N):
    if min > abs(a[i] - ave):
        min_num = i
        min = abs(a[i] - ave)

print(min_num)

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

mean = sum(a)/N
ind = None
min = None
for i in range(N):
    tmp=abs(mean-a[i])
    if min is None:
        min=tmp
        ind=i
    else:
        if tmp<min:
            min=tmp
            ind=i

print(ind)

Solution (Python):

N = int(input())
lst = list(map(int, input().split()))
ave = sum(lst) / len(lst)

lst_diff = []
for i, val in enumerate(lst):
    lst_diff.append(abs(ave - val))
print(lst_diff.index(min(lst_diff)))

Solution (Python):
n = int(input())
p = input()
o = p.split()
k = []
for i in range(n):
    k.append(int(o[i]))
a = sum(k)/n
l = 99999
m = None
for i in range(n):
    w = k[i]
    if (abs(w - a) < l):
        m = i
        l = abs(w - a)
print(m)

Solution (Python):


N = int(input())

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

ave = 0

for n in range(N):
	ave = ave + X_list[n]
ave = ave / N

answer_size = max(X_list)

answer = 0

for n in range(N):
	if answer_size > abs(ave - X_list[n]):
		answer_size = abs(ave - X_list[n])
		answer = n

print(answer)

Solution (Python):
import math

N = int(input())
a = [int(x) for x in input().split()]
mean = sum(a) / N
x = [abs(i-mean) for i in a]
ans = x.index(min(x))
print(ans)

Solution (Python):
import numpy as np
N = int(input())
a = np.array([int(x) for x in input().split(" ")])
indices = np.abs(np.subtract.outer(a, a.mean())).argmin(0)
print(indices)

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

Ave=sum(A)/N
Ans=0
cnt=10000000
for i in range(N):
    if abs(Ave-A[i])<cnt:
        cnt=abs(Ave-A[i])
        Ans=i

print(Ans)