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: Wrong Answer

Solution code:
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 = s-a[i]
        d = i
print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)
print(d.index(min(d)))

Submission status: Wrong Answer

Solution code:
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)
print(b.index(min(b)))

Submission status: Wrong Answer

Solution code:
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 = AAA[i]-ans
print(ans1)

Submission status: Wrong Answer

Solution code:
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(readline())
    A = list(map(int, readline().split()))
    B = sorted(A)
    target = B[(N - 1) // 2]
    for i in range(N):
        if A[i] == target:
            print(i)
            break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
alst = list(map(int, input().split()))
ans = 0
ave = np.average(alst)
d = abs(ave - alst[0])

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

Submission status: Wrong Answer

Solution code:
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:
    ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
A = list(map(int,input().split()))
B = copy.copy(A)
A.sort()
ave = sum(A)/N

ok = 0
ng = N
while abs(ng-ok)>1:
  mid = (ok+ng)//2
  if A[mid] <= ave:
    ok = mid
  else:
    ng = mid
ans = A[ok]

for i in range(N):
  if B[i] == ans:
    print(i)
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a_l = list(map(int, input().split()))
import numpy as np
ave_a = np.mean(a_l)
a_l2 = [  abs(a-ave_a) for a in a_l]
ans = 0
l = a_l2[0]
for idx, i in enumerate(a_l2[1:]):
    if l > i:
        ans = min(idx+1, ans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N,*a = map(int,open(0).read().split())
average = sum(a) // N
b = bisect_left(a,average)
dif = min(average - a[b-1], a[b] - average)
for i in range(N):
    if abs(a[i] - average) == dif:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    heikin=sum(l)//n
    samunenum=100
    samune=10**18
    for i in range(n):
        x=abs(heikin-l[i])
        if x<samune:
            samunenum=i
            samune=x
    print(samunenum)
resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = sum(a)//n
ans = []
for x,y in enumerate(a):
  ans.append([x, abs(m-y)])
ans.sort(key=lambda x:x[1])
print(ans[0][0])

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
l=sorted(list(map(int,input().split())))
mn=sum(l)/n
for i in range(len(l)):
    if l[i]==mn:
        print(i)
        sys.exit()
else:
    if abs(mn-l[i//2-1])<=abs(mn-l[i//2]):
        print(i//2-1)
        sys.exit()
    else:
        print(i//2)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
l=sorted(list(map(int,input().split())))
mn=sum(l)/len(l)
for i in range(len(l)):
    if l[i]==mn:
        print(i)
        sys.exit()
else:
    if abs(mn-l[i//2-1])<=abs(mn-l[i//2]):
        print(i//2-1)
        sys.exit()
    else:
        print(i//2)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
l=sorted(list(map(int,input().split())))
mn=float(sum(l)/len(l))
for i in range(len(l)):
    if l[i]==mn:
        print(i)
        sys.exit()
else:
    if abs(mn-l[i//2-1])<abs(mn-l[i//2]):
        print(i//2-1)
        sys.exit()
    else:
        print(i//2)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
l=sorted(list(map(int,input().split())))
mn=sum(l)/len(l)
for i in range(len(l)):
    if l[i]==mn:
        print(i)
        sys.exit()
else:
    if abs(mn-l[i//2-1])<abs(mn-l[i//2]):
        print(i//2-1)
        sys.exit()
    else:
        print(i//2)
        sys.exit()

Submission status: Wrong Answer

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

g = 0

for x in range(len(a)):
    g += a[x]

g = g/n
i = 0
y = abs(g-a[0])

for x in range(len(a)):
    if y>abs(g-a[x]):
        i = x

print(i)

Submission status: Wrong Answer

Solution code:
n =int(input())
a=[int(x) for x in input().split()]
 
s=sum(a)
ans=0
diff=abs(s-a[0]*n)
for i in range(len(a)):
  if diff>abs(s-a[i]*n):
    diff= abs(s-a[i]*n)
    ans=i
print(i)

Submission status: Wrong Answer

Solution code:
n =int(input())
a=[int(x) for x in input().split()]
 
s=sum(a)
ans=0
diff=abs(s-a[0]*n)
for i in range(len(a)):
  if diff<abs(s-a[i]*n):
    diff= abs(s-a[i]*n)
    ans=i
print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
mu = sum(A) / N
diff = 1000
ans = 0
for a in A:
  if abs(a - mu) < diff:
    diff = abs(a - mu)
    ans = a

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    ave = sum(A)/n
    A.sort()
    d=abs(A[0]-ave)
    for i,a in enumerate(A[1:]):
        if abs(a-ave)<d:
            d=abs(a-ave)
        else:
            print(i)
            break

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    av = sum(a)/n
    aa = list(map(lambda x: abs(x - av), a))
    aa = list(zip(aa, range(n)))
    aa.sort()
    print(aa[1])
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,(input().split())))
tmp = [sum(a)/n for i in range(n)]
average = tmp[0]#これに一番近いもの

x = []

for i in range(n):
    tmp1 = a[i] - average
    if tmp1 < 0:
        tmp1 = tmp1 * -1
    x.append(tmp1)

tmp2 = x[i]
counter = 0
for i in range(1,n-1):
    if tmp2 < x[i]:
        result = x.index(x[i])
    else:
        result = 0

hantei = set(x)
if len(hantei) == 1:
    print(0)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
numlist = list(map(int, input().split()))
cal = 0
for i in numlist:
  cal = cal + i
ave = cal / (n)
dummy = abs(numlist[0]-ave)
index = 0
count = 0
for j in numlist:
  kyori = abs(j-ave)
  if dummy > kyori:
    dummy = kyori
    index = count
  count = count + 1 
print(index+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

goke = 0
ans = 0

for i in range(len(a)):
    goke += a[i]

ave = goke / N

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


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

goke = 0
ans = 0

for i in range(len(a)):
    goke += a[i]

ave = goke / N

ans = 0
for i in range(len(a)-1):
    if abs(ave - a[i]) < abs(ave - a[i+1]):
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
avg = sum(a) / n
a = list(map(lambda x: abs(x - avg), a))
ans = 10 ** 9 + 7
ans_item = 10 ** 9 + 7

for i in range(n):
    if ans_item > a[i]:
        ans = i
        ans_item = a[i]

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_lis = list(map(int, input().split()))
a_sum = sum(a_lis)
a_avg = a_sum / n
minimum = 1000
ans = 0
for i in a_lis:
    n = abs(a_avg - i)
    if n < minimum:
        minimum = n
        ans = i
print(a_lis.index(i) - 1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ave=sum(a)/len(a)
a=np.array(list(map(lambda x:abs(x-ave), a)))
a=a.argsort()
print(a[0])

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    m = sum(a)/n
    f = {}
    for i in range(n):
        if not a[i] in f:
            f[a[i]] = i
    a = list(set(a))
    a.sort()
    i = bisect.bisect_left(a,m)-1
    if abs(m-a[i]) < abs(a[i+1]-m):
        print(f[a[i]])
    elif abs(m-a[i]) < abs(a[i+1]-m):
        print(min(f[a[i]],f[a[i+1]]))
    else:
        print(f[a[i+1]])
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    m = sum(a)/n
    f = {}
    for i in range(n):
        if not a[i] in f:
            f[a[i]] = i
    a = list(set(a))
    a.sort()
    i = bisect.bisect_left(a,m)-1
    if abs(m-a[i]) <= abs(a[i+1]-m):
        print(f[a[i]])
    else:
        print(f[a[i+1]])
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
ave=sum(A)/len(A)
ABS=abs(A[0]-ave)
ans=0
for i,a in enumerate(A):
    if ABS>abs(ave-a):
        ans=i
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
avg = 0
for a in A:
    avg += a
avg = avg / N
B = sorted(A)
target = 0
for b in B:
    dif1 = abs(target-avg)
    dif2 = abs(b-avg)
    if dif2 < dif1:
        target = b
    else:
        break
ans = 0
for i,a in enumerate(A):
    if a == target:
        ans = i
        break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N
ans = 0
sa = 10**9
for i in range(N):
    t = i+1
    x = max(A[i]-ave,ave-A[i])
    if x < sa:
        sa = x
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
avg = sum(a)/n
difmin = 10**18
for i in range(n):
  if difmin>abs(a[i]-avg):
    difmin = abs(a[i]-avg)
    ans = i
print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
sum = sum(a)
min = 10000000
ans = 0
for i in range(n):
    if abs(sum - (a[i] * n)) < min:
        min = sum - (a[i] * n)
        ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

b = []
s = int(sum(a)/len(a))
for i in range(len(a)):
    b.append(abs(a[i]-s))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
mean = sum(alist) / N
alist = alist - mean
print(np.argmin(alist))

Submission status: Wrong Answer

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


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

A = np.array(A, dtype=int)
A -= A.mean()
A = np.abs(A)
ans = A.argmin()

print(ans)

Submission status: Wrong Answer

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

mean=sum(A)/len(A)
ans=0
for i,a in enumerate(A):
  if abs(ans-mean)>abs(a-mean):
    ans=i
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)//n
count=1000000000
ans=0
for j in range(len(a)):
    if abs(a[j]-ave)<count:
        count=abs(a[j]-ave)
        ans=j
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
average = sum(a) / N
A = list(map(lambda n:abs(n-average), a))
A.sort()
A1 = int(average - A[0])
A2 = int(average + A[0])
if A1 in a:
    B1 = a.index(A1)
else:
    B1 = 10**18
if A2 in a:
    B2 = a.index(A2)
else:
    B2 = 10**18

print(min(B1, B2))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
average = sum(a) / N
A = list(map(lambda n:abs(n-average), a))
A.sort()
A1 = int(average - A[0])
if A1 in a:
    print(a.index(A1))
else:
    print(a.index(int(average + A[0])))

Submission status: Wrong Answer

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]
    print(sum)
ave = sum/N
print(ave)
#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: Wrong Answer

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

Ave = sum(A)/len(A)
# print('Ave:',Ave)
abs_distance = list()

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

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

Submission status: Wrong Answer

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

Ave = sum(A)/len(A)
# print('Ave:',Ave)
abs_distance = list()

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

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

Submission status: Wrong Answer

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

Ave = sum(A)/len(A)
# print('Ave:',Ave)
abs_distance = list()

for i in range(len(A)):
    abs_distance.append(int(abs(A[i]-Ave)))
    # print(int(abs(A[i]-Ave*N)))
# print(abs_distance)

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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]
print(ave_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: Wrong Answer

Solution code:
import numpy as np

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

avg = int(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: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
sums = sum(A)/N
avg = round(sums)
avg2 = avg+1 if avg == int(sums) else avg-1

tmp = 100
result = 0
for i in range(N):
    if A[i] == avg:
        result = i
        break
    if A[i] == avg2 and tmp > i:
        tmp = i

print(result if A[result] == avg or result < tmp else tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
sums = sum(A)/N
avg = round(sums)
avg2 = avg+1 if avg == int(sums) else avg-1

tmp = 100
result = 0
for i in range(N):
    if A[i] == avg:
        result = i
        break
    if A[i] == avg2 and tmp > i:
        tmp = i

print(result if result < tmp or result == avg else tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
sums = sum(A)/N
avg = round(sums)
avg2 = avg+1 if avg == int(sums) else avg-1

tmp = 100
result = 0
for i in range(N):
    if A[i] == avg:
        result = i
        break
    if A[i] == avg2 and tmp > i:
        tmp = i

print(result if result < tmp else tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
a = sorted(A.copy())
sums = sum(A)/N
avg = round(sums)
avg2 = avg+1 if avg == int(sums) else avg-1

tmp = 100
result = 0
for i in range(N):
    if A[i] == avg:
        result = i
        break
    if A[i] == avg2 and tmp > i:
        tmp = i

print(result if result < tmp else tmp)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
A = list(map(int, input().split()))
sums = sum(A)/N
avg = round(sums)
avg2 = avg-1 if avg == math.ceil(sums) else avg+1

result = 0
for i in range(N):
    if A[i] == avg:
        result = i
        break
    if A[i] == avg2:
        result = i
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
avg = round(sum(A)/N)
result = 0
for i in range(N):
    if A[i] == avg:
        result = i
        break
print(result)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N = int(input())
a = sorted(list(map(int, input().split())))
Ave = sum(a) / N
tmp = float("inf")
for i in range(N):
	if abs(a[i] - Ave) < tmp:
		tmp = abs(a[i] - Ave)
		ans = i
print(ans)

Submission status: Wrong Answer

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 < 1:
		break
print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print( ans )

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(int((int(input())-1)/2))

Submission status: Wrong Answer

Solution code:
print(int((int(input())+1)/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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+1
print(c)

Submission status: Wrong Answer

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

sum = 0

for i in a:
  sum += i
  
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: Wrong Answer

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

sum = 0

for i in a:
  sum += i
  
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

print(result)

Submission status: Wrong Answer

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 int(abs(data[i] - ave)) < int(abs(data[ans] - ave)):
    ans = i

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(thumbnail_num)

Submission status: Wrong Answer

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 a[i]-avg < mdif:
        mdif = a[i] - avg
        flag = i
print(flag)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 abs(a[i]-ave) < b:
    b = a[i]-ave
    c = i
print(c)

Submission status: Wrong Answer

Solution code:
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-1):
  if abs(a[i]-ave) < b:
    b = a[i]-ave
    c = i
print(c)

Submission status: Wrong Answer

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

p = sum(A)/N
q = 10**9+7
for i in range(N) :
	r = abs(p - A[i])
	if r < q :
		r = q
		ans = i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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(su-n*l[i]<best):
    best=su-n*l[i]
    res=i
print(res)

Submission status: Wrong Answer

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

mean = sum(a)/N

a = list(map(lambda x: int(abs(x-mean)), a))

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

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
n = int(input())
a = [int(i) for i in input().split()]
x,m = [],sum(a)
for i in range(n): x.append((a[i]*n,i))
x.sort()
b = bisect_left(x,(m,-1))
if b==0: print(0)
elif m-x[b-1][0]>x[b][0]-m: print(x[b][1])
else:
	for i in range(b-2,-2,-1):
		if x[b-1][0]!=x[i][0]: break
	if x[b][0]-x[b-1][0]==2*m: print(min(x[b][1],x[i+1][1]))
	else: print(x[i+1][1])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
n = int(input())
a = [int(i) for i in input().split()]
x,m = [],sum(a)
for i in range(n): x.append((a[i],i))
x,m = sorted(x),m/n
b = bisect_left(x,(m,-1))
if b==0: print(0)
elif m-x[b-1][0]>x[b][0]-m: print(x[b][1])
else:
	for i in range(b-2,-2,-1):
		if x[b-1][0]!=x[i][0]: break
	if x[b][0]-x[b-1][0]==2*m: print(min(x[b][1],x[i+1][1]))
	else: print(x[i+1][1])

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
print(min(a)%998244353)

Submission status: Wrong Answer

Solution code:
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:
    print ("%d" % x)
    s = abs(x-ave)
    if s < dif:
        dif = s
        ans = count
    count += 1
  
print("%d" % ans)