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.



Sample input:
3
1 2 3


Sample output:
1

Submission status: Accepted

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

ans = -1
dif = 10000
for i, ai in enumerate(a):
    d = abs(ai-ave)
    if d < dif:
        dif = d
        ans = i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
li_a = list(map(int, input().split()))

ave = sum(li_a) / n
minimum = min(abs(ave - a)for a in li_a)

for idx, v in enumerate(li_a):
    if abs(ave - v) == minimum:
        print(idx)
        exit(0)

Submission status: Accepted

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

min_a=10**10
for i,a in enumerate(A):
  if min_a>abs(ave_A-a):
    min_a=abs(ave_A-a)
    min_i=i
    
print(min_i)

Submission status: Accepted

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

ans=0
min_diff=max(a)

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

Submission status: Accepted

Solution code:
def main():

    N = int(input())
    A = list(map(int, input().split()))
    ave = sum(A)/N
    min_d = float('inf')
    min_i = None
    for i in range(N):
        d = abs(A[i]-ave)
        if d < min_d:
            min_d = d
            min_i = i
    return min_i

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
N = int(input())
As = list(map(int, input().split()))
s = sum(As)
r = min(range(N), key=lambda i: abs(N*As[i]-s))
print(r)

Submission status: Accepted

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

avg = sum(A) / N

L = []
for i in range(N):
    L.append((i, abs(avg - A[i])))

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

print(L[0][0])

Submission status: Accepted

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

avg= sum(a)/N
sabun=sum(a)
ans=0
for j in range(N):
    if abs(a[j]-avg) < sabun:
        ans=j
        sabun = abs(a[j]-avg)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ret = N
tmp = float("inf")
for i,flame in enumerate(arr):
    if abs(ave - flame) < tmp:
        tmp = abs(ave - flame)
        ret = i
print(ret)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
ave = sum(a) / len(a)
result = -1
tmp = float('inf')
for i, ai in enumerate(a):
    if tmp > abs(ai - ave):
        tmp = abs(ai - ave)
        result = i
print(result)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[abs(_-(sum(A)/N)) for _ in A]
for _ in range(N):
    if B[_]==min(B):
        print(_)
        exit()

Submission status: Accepted

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

ave = sum(a)/(N)
index = 0
min_sa = 10000
for i,j in enumerate(a):
    if min_sa > abs(j-ave):
        index = i
        min_sa = abs(j-ave)
print(index)

Submission status: Accepted

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

mean = sum(a) / N

a_dif = [(i, abs(v-mean)) for i,v in enumerate(a)]

a_dif = sorted(a_dif, key=lambda x:x[1])
print(a_dif[0][0])

Submission status: Accepted

Solution code:
import decimal

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

mean = sum(a)/N
min  = float('inf') 

min_id = 0

for i, ai in enumerate(a):
  diff = abs(ai-mean)
  if(diff < min):
    min = diff
    min_id = i
  
print(min_id)

Submission status: Accepted

Solution code:
from numpy import*;_,a=open(0);a=int8(a.split());print(argmin(abs(a-mean(a))))

Submission status: Accepted

Solution code:
N,*A=map(int,open(0).read().split());print(min([[i,abs(v-sum(A)/N)] for i,v in enumerate(A)],key=lambda x:x[1])[0])

Submission status: Accepted

Solution code:
def solve(n, a):
    b = sum(a) / n
    ans = 0
    best = abs(a[0] - b)
    for i in range(n):
        c = abs(a[i] - b)
        if c < best:
            ans, best = i, c
    return ans

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
x = np.abs(a - a.mean())
print(np.argmin(x))

Submission status: Accepted

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

Submission status: Accepted

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

ave = sum(a) / N
check = []

for i in range(N):
    check.append([abs(ave - a[i]), i])

check.sort()
print(check[0][1])

Submission status: Accepted

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

avg = sum(a) / len(a)
diff = list(map(lambda x : abs(x - avg), a))
min_diff = min(diff)
for i in range(n):
    if abs(a[i] - avg) == min_diff:
        print(i)
        break

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
nums = list(map(int,input().split(" ")))
avr = sum(nums)/N
diff = 10 ** 9
ans = 0
for i,num in enumerate(nums):
  if diff > abs(avr - num):
    ans = i
    diff = abs(avr - num)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

S = sum(A)
best_diff = 10**18
best_i = -1
for i,x in enumerate(A):
    d = abs(x*N-S)
    if d < best_diff:
        best_diff = d
        best_i = i

print(best_i)

Submission status: Accepted

Solution code:
n = int(input())
flame_list = [ int(v) for v in input().split() ]

mean = sum(flame_list)/n

flame_list_2 = [ abs(mean - i) for i in flame_list ]


print(flame_list_2.index(min(flame_list_2)))

Submission status: Accepted

Solution code:
from statistics import mean

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

avg = mean(a)

tmp = []
result = []
for x in a:
    tmp.append(abs(x - avg))
    
tmp_min = min(tmp)
for i in range(len(tmp)):
    if tmp[i] == tmp_min:
        print(i)
        break

Submission status: Accepted

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

av = sum(a) / N
mi = 101
c = 0
for i in range(N - 1, -1, -1):
    if abs(a[i] - av) <= mi:
        mi = abs(a[i] - av)
        idx = i
print(idx)

Submission status: Accepted

Solution code:
N = int(input())
vA = list(map(int, input().split()))

aveA = sum(vA) / N
vD = [abs(a - aveA) for a in vA]

res = vD.index(min(vD))
print(res)

Submission status: Accepted

Solution code:
n=int(input())
A=tuple(map(int,input().split()))
ave=sum(A)/n
d=float('inf')
for i,a in enumerate(A):
    if abs(a-ave)<d:
        d=abs(a-ave)
        ans=i
print(ans)

Submission status: Accepted

Solution code:
# dwacon5th-prelimsA - Thumbnail
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    avg = sum(A) / N
    D = {(abs(avg - a), i) for i, a in enumerate(A)}
    print(min(D)[1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# dwacon5th-prelimsA - Thumbnail
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    avg = sum(A) / N
    D = [(abs(avg - a), i) for i, a in enumerate(A)]
    print(min(D)[1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# dwacon5th-prelimsA - Thumbnail
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    avg = sum(A) / N
    D = sorted((abs(avg - a), i) for i, a in enumerate(A))
    print(D[0][1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int,input().split()))
sum = 0
ave = 0
ave_first = 99999
k = []
#sum は合計、aveは平均値 ave_first は絶対値の平均値との比較 
# kはもっとも近いフレーム番号のリスト
for i in range(N):
    sum += P[i]
ave = sum/N
#aveを平均値とする
for i in range(0,N-1):
    if abs(P[i]-ave)< ave_first:
            ave_first = abs(P[i]-ave)
            k.clear()
            k.append(i)
    elif abs(P[i]-ave) == ave_first:
        k.append(i)
print(min(k))

Submission status: Accepted

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

avg = sum(A) / N

ans = -1
ms = 100
for i, a in enumerate(A):
    if abs(a - avg) < ms:
        ms = abs(a - avg)
        ans = i
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
avg=sum(A)/N
l=200
ans=0
for i in range(N):
  if abs(avg-float(A[i]))<l:
    l=abs(avg-float(A[i]))
    ans=i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
framelist = [int(i) for i in input().split()]

sum = 0


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

avg = sum /n

min = avg
value = 0

for i in range(n):
  difference = abs(framelist[i]-avg)
  if min>difference:
    min = difference
    value = framelist[i]
    
print(framelist.index(value))

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
sum=0
for i in a:
        sum+=i
sum/=N
mini=100000000
k=0
for i in a:
        if mini>abs(i-sum):
                mini=abs(i-sum)
                ans=k
        k+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ave = sum(a)/n
b = [abs(a[i]-ave) for i in range(n)]
ans = 0
m = 1000000
for i in range(n):
    if b[i] < m:
        m = b[i]
        ans = i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
al=list(map(int,input().split()))
t=sum(al)/n
ta=100
for i in range(n):
    if abs(t-al[i])<ta:
        ta=abs(t-al[i])
        ans=i
print(ans)

Submission status: Accepted

Solution code:
n =int(input())

li = list(map(int,input().split()))
av = sum(li) / n


ans = 0
tp = abs(li[ans] - av)
for i in range(1,n):
    if(abs(li[i] - av) < tp):
        tp = abs(li[i] - av)
        ans = i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Ave = sum(A)/len(A)
abs_distance = list()

for i in range(N):
    abs_distance.append(abs(A[i]-Ave))

print(abs_distance.index(min(abs_distance)))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
mean = sum(A) / N
ans = 0
diff = abs(A[0]-mean)
for i in range(1, N):
    if diff > abs(A[i]-mean):
        diff = abs(A[i]-mean)
        ans = i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
ave=sum(l)/n
ans=None
c=100000 
for i in range(n):
  if abs(ave-l[i])<c:
    ans=i;c=abs(ave-l[i])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(item) for item in input().split()]
ave = sum(a) / n

diff = []
for i, item in enumerate(a):
    diff.append([abs(item - ave), i])
diff.sort()
print(diff[0][1])

Submission status: Accepted

Solution code:
N=int(input())
alist=list(map(int,input().split()))

avg=sum(alist)/N
min_index=-1
min_diff=1000
for i in range(N):
  diff=abs(avg-alist[i])
  if diff<min_diff:
    min_diff=diff
    min_index=i
    
print(min_index)

Submission status: Accepted

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

avg = sum(A) / N
diff = [(abs(A[i] - avg), i) for i in range(N)]
diff.sort()

print(diff[0][1])

Submission status: Accepted

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

ave=(sum(a)/N)

ave_a=[abs(i-ave) for i in a]

ans=101
thum=101
for i in range(N):
    if ave_a[i]<thum:
        thum=ave_a[i]
        ans=i

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
A=[int(i) for i in input().split()]
mean=sum(A)/n
ans=-1
dif=float("inf")
for i in range(n):
  if abs(A[i]-mean)<dif:
    dif=abs(A[i]-mean)
    ans=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ave=sum(a)/N

mini=1000
argmin=-1
for i in range(N):
  if abs(ave-a[i])<mini:
    mini=abs(ave-a[i])
    argmin=i
    
print(argmin)

Submission status: Accepted

Solution code:
N=int(input())
listA=list(map(int,input().split()))
ave=sum(listA)/N
sub=[]
for i in range(N-1,-1,-1):
  sub+=[abs(listA[i]-ave)]
  if min(sub)==abs(listA[i]-ave):
    ans=i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
*A, = map(int, input().split())
mean = sum(A)/N
_, i = min([(abs(a - mean), i) for i, a in enumerate(A)])
print(i)

Submission status: Accepted

Solution code:
import numpy as np

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

avg = np.average(a)

def delta(tsumugi):
  return tsumugi - avg

a_delta = list(map(delta, a))
a_abs = list(np.abs(a_delta))
num_min = np.min(a_abs)
index = a_abs.index(num_min)

print(index)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    a = list(map(int, input().split()))
    avg = sum(a) / N
    min_abs = float("inf")
    min_frame = 0
    for i in range(N):
        score = abs(a[i] - avg)
        if score < min_abs:
            min_abs = score
            min_frame = i
    print(min_frame)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
mid=sum(L)/len(L)
LL=[abs(i-mid) for i in L]
print(LL.index(min(LL)))

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ave = sum(a)/len(a)
min_diff = max(a)
for i in range(n):
    diff = abs(a[i]-ave)
    if diff < min_diff:
        min_diff = diff
        ans = i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
sums = sum(A)
sml = [abs(N*A[i]-sums) for i in range(N)]

tmp = 100
result = 0
for i, n in enumerate(sml):
    if tmp > n:
        result = i
        tmp = n

print(result)

Submission status: Accepted

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

s = sum(A)

answer = 0
min_dist = 10**10
for i,a in enumerate(A):
  d = abs(N*a-s)
  if min_dist > d:
    min_dist = d
    answer = i

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
N = int(input())
As=list(map(int,input().split()))
ave = sum(As)/len(As)
minindexs = []
ave = [abs(As[i]-ave) for i in range(len(As))]
print(ave.index(min((ave))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())
As = list(mi())
avg = sum(As) / N

minno = -1
min = 1000
for i, a in enumerate(As):
  if abs(a-avg) < min:
    min = abs(a-avg)
    minno = i

print(minno)

Submission status: Accepted

Solution code:
N = int(input())
a_lst = list(map(int, input().split()))

avr = sum(a_lst) / N

ans = 0
x = -1
for i in range(N):
    if x == -1 or x > abs(a_lst[i] - avr):
        x = abs(a_lst[i] - avr)
        ans = i

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=list(range(N))
AB=[]
mean=sum(A)/N
for i in range(N):
    AB.append([abs(A[i]-mean),B[i]])
AB.sort()
print(AB[0][1])

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)/n
b=[]
for i in range(n):
        b.append((a[i],abs(a[i]-ave),i))
b=sorted(b,key=lambda x:(x[1],x[2]))
print(b[0][2])

Submission status: Accepted

Solution code:
n = int(input())
a = list(int(i) for i in input().split())
avg = sum(a) / n
ansa = 999
ansn = 0
for x in range(n):
  if ansa > abs(avg - a[x]):
    ansa = abs(avg - a[x])
    ansn = x
print(ansn)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
f=sum(a)/n
x,y=float("inf"),0
for i in range(n):
    if x>abs(f-a[i]):
        x=abs(f-a[i])
        y=i
print(y)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
S = sum(A)

ans = 10**12
Ans = None
for i, a in enumerate(A):
    if abs(S - N*a) < ans:
        ans = abs(S - N*a)
        Ans = i
print(Ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N
ans = 0
dist = 1000
for i, a in enumerate(A):
	if abs(a - ave) < dist:
		ans = i
		dist = abs(a - ave)
	if dist < 0.5:
		break
print(ans)

Submission status: Accepted

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

ave_a = sum(a) / n
dist = 1000007
flamenum = 0

for i in range(n):
    if abs(a[i] - ave_a) < dist:
        dist = abs(a[i] - ave_a)
        flamenum = i
        #print(dist)

print(flamenum)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
avg=sum(A)/N
AN=[abs(a-avg) for a in A]
print(AN.index(min(AN)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
mean = sum(a)/len(a)

tmp1 = 10000
tmp2 = 0

for i in range(len(a)):
  if abs(a[i]-mean) < tmp1 :
    tmp1 = abs(a[i]-mean) 
    tmp2 = i
    
#print(tmp1)
print(tmp2)

Submission status: Accepted

Solution code:
N = int(input())
a_s = [int(x) for x in input().split()]

mean = sum(a_s) * 1.0 / N
d = min(map(lambda a: abs(a - mean), a_s))
ans = N
for i in range(N):
    if abs(a_s[i] - mean) == d:
        ans = i
        break

print(ans)

Submission status: Accepted

Solution code:
if __name__=="__main__":
    n = int(input())
    a = [int(i) for i in input().split(' ')]
    ave = 0.0
    for i in a:
        ave += i
    ave /= n
    ans = 0
    for id, i in zip(range(n), a):
        if abs(a[ans] - ave) > abs(i - ave):
            ans = id
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
ave = sum(A)/n 
diff = []  
for a in A:
	diff.append(abs(a-ave))
tmp = 0   
d = 10**9
for i in range(n):
	if diff[i] < d:
		d = diff[i]
		tmp = i
print(tmp)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=sum([e/len(a)for e in a])
s=[abs(e-m) for e in a]
print(s.index(min(s)))

Submission status: Accepted

Solution code:
n=int(input())
arr=list(map(int,input().split()))
avg=sum(arr)/n
pos=0
diff=10**9
for i in range(n):
  if abs(arr[i]-avg)<diff:
    diff=abs(arr[i]-avg)
    pos=i
print(pos)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
m = np.mean(a)
ans = 0
dist = abs(a[0] - m)

for i in range(n):
    if abs(a[i] - m) < dist:
        dist = abs(a[i] - m)
        ans = i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from numpy import*;_,a=open(0);a=int32(a.split());print(argmin(abs(a-mean(a))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from statistics import mean

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

A = list(map(lambda i: abs(i - mean(A)), A))

print(A.index(min(A)))

Submission status: Accepted

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

ave = sum(a)/N
ans = 0
dif = 1e+3
for i in range(N):
    if abs(a[i] - ave) < dif:
        ans = i
        dif = abs(a[i] - ave)

print( ans )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
m = list(map(int, input().split()))
avg = sum(m) / n
print(min([(abs(e - avg), i) for i, e in enumerate(m)])[1])

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split(' ')))
m=sum(A)/N
B=[abs(a-m) for a in A]
print(B.index(min(B)))

Submission status: Accepted

Solution code:


def main():
    N = int(input())
    a = list(map(int, input().split()))
    ave_a = sum(a)/len(a)

    best_diff = abs(a[0] - ave_a)
    best_i = 0
    for i, aa in enumerate(a):
        diff = abs(ave_a - aa)
        if diff < best_diff:
            best_i = i
            best_diff = diff

    print(best_i)

main()

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
a = list(map(int, input().split()))
num = sum(a)/n
idx = np.abs(np.asarray(a) - num).argmin()
print(idx)

Submission status: Accepted

Solution code:
N = int(input())
a = [int(_) for _ in input().split()]
ave = sum(a)/N
Min = sum(a)
res = 0

for i in range(N):
    if abs(ave - a[i]) < Min:
        Min = abs(ave - a[i])
        res = i

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
a = list(map(int,input().split()))
ave = sum(a)/len(a)
ans = 10e12
tmp = 0
ans_num = 0
for i in range(len(a)):
  tmp = abs(a[i] - ave)
  if ans > tmp:
    ans = tmp
    ans_num = i
print(ans_num)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from numpy import*;input();*a,=map(int,input().split());print(argmin(abs(a-mean(a))))

Submission status: Accepted

Solution code:
from numpy import*;n,*a=map(int,open(0).read().split());print(argmin(abs(a-mean(a))))

Submission status: Accepted

Solution code:
from numpy import*;n,*a=map(int,open(0).read().split());print(argmin(abs(a-sum(a)/n)))

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split());b=[abs(i-sum(a)/n)for i in a];print(b.index(min(b)))

Submission status: Accepted

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
ave=sum(a)/len(a)
A=[(abs(a[i]-ave),i) for i in range(n)]
A.sort()
print(A[0][1])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
num = list(map(int,input().split()))
ave = sum(num) / n
dis = [abs(num[i]-ave) for i in range(n)]
print(dis.index(min(dis)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
m = 10 ** 10
mi = 0
for i, e in enumerate(a):
    if abs(e*n - s) < m:
        m = abs(e*n - s)
        mi = i
print(mi)

Submission status: Accepted

Solution code:
from statistics import mean

frame_num = int(input())
frame_value = list(map(int, input().split()))
avg = mean(frame_value)
min_frame = max(frame_value)
thumbanil = 0
for frame, value in enumerate(frame_value):
    diff = abs(avg - value)
    # print(diff, value, frame)
    if diff < min_frame:
        min_frame = diff
        thumbanil = frame

print(thumbanil)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
S = sum(A)
ave = S/N
L = []
for i in range(N):
  L.append([abs(A[i]-ave),i])
L.sort()
print(L[0][1])

Submission status: Accepted

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

average=sum(a)/N
#print(a)
#print(average)
b=list(map(lambda x:abs(x-average),a))
print(b.index(min(b)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(int(i) for i in input().split())
average = sum(a)
query =[]
for i in a:
 query.append(abs(n*i-average))
print(query.index(min(query)))

Submission status: Accepted

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

sum = sum(a)
avg = sum/N

result = 0
tmp = 0

for i in range(len(a)):
  ans = avg - a[i]
  ans = ans if ans > 0 else ans * -1
  if i == 0:
    result = i
    tmp = ans
  elif tmp > ans:
    result = i
    tmp = ans

print(result)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
aN = LIST()
avg = sum(aN) / len(aN)
aN2 = [[0] * 2 for i in range(N)]
for i in range(N):
    aN2[i][0] = i
    aN2[i][1] = abs(aN[i] - avg)

aN2.sort(key=itemgetter(1))
print(aN2[0][0])

Submission status: Accepted

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
b = sum(ar) / a
s = abs(ar[0] - b)
ans = 0
for i in range(1,a):
    if s > abs(b - ar[i]):
        s = abs(b - ar[i])
        ans = i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
data = list(map(int, input().split()))
ave = sum(data) / len(data)
ans = 0
for i in range(len(data)):
  if abs(data[i] - ave) < abs(data[ans] - ave):
    ans = i

print(ans)

Submission status: Accepted

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

mean = sum(a)/len(a)

ans = 0
for i in range(len(a)):
    if abs(a[ans]-mean)>abs(a[i]-mean):
        ans = i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
at = input().split(" ")
a = []
for i in at:
    a.append(int(i))
avg = sum(a) / N
mdif, flag = abs(a[0]-avg), 0
for i in range(len(a)):
    if abs(a[i]-avg) < mdif:
        mdif = abs(a[i]-avg)
        flag = i
print(flag)

Submission status: Accepted

Solution code:
N = int(input())
a_list = list(map(int,input().split()))
ave = sum(a_list)/N
abs_list = [abs(i - ave) for i in a_list]
print(abs_list.index(min(abs_list)))

Submission status: Accepted

Solution code:
import statistics as st
N = int(input())
a = [int(x) for x in input().split()]
m = st.mean(a)

#print(m)#
nbr = abs(a[0]-m)
idx = 0
for i in range(1,N):
    if abs(a[i]-m)<nbr:
        nbr = abs(a[i]-m)
        idx = i
print(idx)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
ave = sum(x)/len(x)
MIN = abs(x[0]-ave)
MIN_index = 0
for i,j in enumerate(x):
  if abs(j-ave) < MIN:
    MIN_index = i
    MIN = abs(j-ave)
print(MIN_index)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
average = sum(a)/N
minv = 101
minframe = 0
for i in range(N):
    diff = abs(a[i] - average)
    if diff < minv:
        minv = diff
        minframe = i

print(minframe)

Submission status: Accepted

Solution code:
import numpy as np

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

avg = np.sum(a) / len(a)

x = np.abs(a - avg)

print(np.argmin(x))

Submission status: Accepted

Solution code:
n =int(input())
a = list(map(int,input().split()))
q = sum(a)/n
#print(q)
d = q
e = 1000
for i in range(n-1,-1,-1):
    if d >= abs(q-a[i]):
        d = abs(q-a[i])
        e = i
print(e)

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
#frames=[]

frames=list(map(int, input().split(" ")))
ave=sum(frames)/N

ans=np.abs(np.asarray(frames)-ave).argmin()
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
ave = sum(a)/N
ans = 0
min = 100
for i in range(N):
    if abs(a[i]-ave) < min:
        min = abs(a[i]-ave)
        ans = i

print(ans)