ZhenlongDai/ACPR huggingface dataset:
Problem: p03763
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

n = int(input())
S = [input() for i in range(n)]

counter = [defaultdict(lambda: 0) for i in range(n)]
for i in range(n):
    for c in S[i]:
        counter[i][c] += 1
        
all_counter = defaultdict(lambda: 0)
for s in counter[0]:
    all_counter[s] += counter[0][s]
    
for i in range(1,n):
    for s in all_counter:
        all_counter[s] = min(counter[i][s], all_counter[s])
        
        
        
        
        
    
for s in all_counter:
    print(s* all_counter[s], end='')

Failing test case input:
3
cbaa
daacc
acacac

Expected output:
aac

Actual output:
caa

Fixed submission (verdict: Accepted):
from collections import defaultdict

n = int(input())
S = [input() for i in range(n)]

counter = [defaultdict(lambda: 0) for i in range(n)]
for i in range(n):
    for c in S[i]:
        counter[i][c] += 1
        
all_counter = defaultdict(lambda: 0)
for s in counter[0]:
    all_counter[s] += counter[0][s]
    
for i in range(n):
    for s in all_counter:
        all_counter[s] = min(counter[i][s], all_counter[s])

for s in sorted(all_counter, key=lambda x: x[0]):
    print(s* all_counter[s], end='')
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
0 5 6 5

Expected output:
1


Actual output:
3


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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
3 9 3 5

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)
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)

Failing test case input:
4
-1 2 12 7

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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]])

Failing test case input:
4
0 14 6 4

Expected output:
2


Actual output:
6


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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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[1],x[0]))


print(a[0][0])


Failing test case input:
4
1 19 18 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
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])
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
P = int(input())
N = list(map(int,input().split()))
N.reverse()

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

Failing test case input:
4
-8 0 3 1

Expected output:
1


Actual output:
-1.0
2.0 0 1
2.0 1 3
1.0 2 0
1.0 3 -8
1


Fixed submission (verdict: Accepted):
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)))

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())

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

c = sum(b)
d = 10000
for i in range(a):
	if abs(b[i]-c) <= d:
		d = abs(b[i]-c)

for i in range(a):
	if abs(b[i]-c) == d:
		print(i)
		break

Failing test case input:
4
-1 2 12 9

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
a = int(input())

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

c = sum(b)/a
d = 10000
for i in range(a):
	if abs(b[i]-c) < d:
		d = abs(b[i]-c)

for i in range(a):
	if abs(b[i]-c) == d:
		print(i)
		break

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
2 5 3 5

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
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(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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 = i-avg
print(mnn)

Failing test case input:
4
-4 0 3 8

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-7 0 1 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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)
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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())
print(c[0][0])


Failing test case input:
4
0 13 12 2

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
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])

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
l = []
ave = sum(a)/n

diff = 1000
res = 0

for i in range(len(a)):
    if diff > abs(ave-a[i]):
        res = i
        diff = ave-a[i]
else:
    print(res)


Failing test case input:
4
-7 1 3 0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
l = []
ave = sum(a)/n

diff = 1000
res = 0

for i in range(len(a)):
    if diff > abs(ave-a[i]):
        res = i
        diff = abs(ave-a[i])
else:
    print(res)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)
	

Failing test case input:
4
3 4 3 5

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-8 0 4 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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(ans))

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-8 0 4 2

Expected output:
1


Actual output:
7.5
0.5
1


Fixed submission (verdict: Accepted):
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(flamenum)
Problem: p03214
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
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)
    

Failing test case input:
4
-8 0 3 1

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
INF = float("inf")
ave = sum(A)/N
MIN = INF

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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
5 14 6 5

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
0 0 6 5

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
0 19 13 3

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
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)
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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]):
        break
    if min > abs(mean - a[i]):
        min = abs(mean - a[i])
        ans = i
print(ans)


Failing test case input:
4
0 20 18 2

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)))

Failing test case input:
4
0 0 6 5

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
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)))

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-4 1 3 8

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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)):
    if abs(ave-a[ans]) > abs(ave - a[i]):
        ans = i


print(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-4 0 4 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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 = avr - num[i]
        pos = i
print(pos)


Failing test case input:
4
-7 1 3 0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
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)
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
0 1 3 4

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
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(n):
  if diff>abs(s-a[i]*n): 
    diff= abs(s-a[i]*n)
    ans=i
print(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-7 1 3 0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
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 = abs(sum - (a[i] * n))
        ans = i
print(ans)

Problem: p03214
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)
  

Failing test case input:
4
-4 0 3 8

Expected output:
2


Actual output:
1


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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from statistics import mean
N = int(input())
a=list(map(int,input().split(' ')))

avg=mean(a)

b=[]
for i in range(N):
    b.append(abs(a[i]-avg) )


c=sorted(b)

for i in range(N):
    if c[i]==min(b):
        print(i)
        exit(0)


Failing test case input:
4
0 13 12 2

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
from statistics import mean
N = int(input())
a=list(map(int,input().split(' ')))

avg=mean(a)

b=[]
for i in range(N):
    b.append(abs(a[i]-avg) )




for i in range(N):
    if b[i]==min(b):
        print(i)
        exit(0)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
5 14 6 5

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))

mean = sum(A)/N
ans = 0
p = 10**9 + 7
for i in range(N) :
    q = abs(A[i] - mean)
    if q < p :
        p = q
        ans = i
print(ans)
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-2 2 6 9

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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
        tmp = abs(ave - a[i])
print(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
0 19 13 2

Expected output:
2


Actual output:
13


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
mu = sum(A) / N
diff = 1000
ans = 0
for i, a in enumerate(A):
  if abs(a - mu) < diff:
    diff = abs(a - mu)
    ans = i

print(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-4 2 4 4

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
5 14 3 5

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
-4 0 3 8

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
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)
Problem: p03214
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)

Failing test case input:
4
0 1 12 9

Expected output:
3


Actual output:
5.5
3


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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-2 2 4 4

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
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(flamenum)

Problem: p03214
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)

Failing test case input:
4
5 0 3 5

Expected output:
2


Actual output:
0


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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

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

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


Failing test case input:
4
-4 3 4 7

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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)


Failing test case input:
4
-8 0 3 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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)
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from statistics import mean
n = int(input())
a = list(map(int, input().split()))

m = mean(a)
Min = abs(a[0]-m)
ret = [0]

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

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

Failing test case input:
4
0 1 12 9

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
1 19 12 3

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
-7 0 3 2

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
b = [int(i) for i in input().split()]


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

c = sorted(c.items())
if len(c)==1:
	print(0)
else:
	print(c[0][1])


Failing test case input:
4
2 4 3 5

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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])

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)))


Failing test case input:
4
-2 2 4 9

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,input().split()))

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

print(b.index(min(b)))
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)))

Failing test case input:
4
0 0 6 5

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
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)))

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=a[i]
ave=sum
min=abs(a[0]-ave)
ans=0
for i in range(1,n):
  if (abs(a[i]-ave)<min):
    min=abs(a[i]-ave)
    ans=i
print(ans)

Failing test case input:
4
-4 1 4 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=a[i]
ave=sum/n
min=abs(a[0]-ave)
ans=0
for i in range(1,n):
  if (abs(a[i]-ave)<min):
    min=abs(a[i]-ave)
    ans=i
print(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int,input().split()))
Mean = sum(a)/N
a_norm = [a[i] - Mean for i in range(N)]
print(a_norm.index(min(a_norm)))

Failing test case input:
4
5 14 6 5

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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)))

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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 )

Failing test case input:
4
0 5 6 5

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
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 )

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys

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


def inpl(): return list(map(int, input().split()))


N = int(input())
A = inpl()
B = set(A)
m = sum(A)/N
tmp = INF
min_num = A[0]
for b in B:
    if abs(b - m) < tmp:
        tmp = abs(b - m)
        min_num = b

print(A.index(min_num))


Failing test case input:
4
2 4 3 5

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):


import sys

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


def inpl(): return list(map(int, input().split()))


N = int(input())
A = inpl()
m = sum(A)/N
tmp = INF
min_num = A[0]
for b in A:
    if abs(b - m) < tmp:
        tmp = abs(b - m)
        min_num = b

print(A.index(min_num))
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)))

Failing test case input:
4
-1 2 12 7

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
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)))

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
average = sum(a)
minv = 101
minframe = 0
for i in range(N):
    diff = abs(a[i] - average)
    if diff < minv:
        minv = diff
        minframe = i

print(minframe)

Failing test case input:
4
0 4 12 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
0 13 12 2

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
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 = abs(sum - (a[i] * n))
        ans = i
print(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
ave_a = sum(a) / n
sa = 101
min_ind = 0
for i in range(n):
    print(abs(a[i] - ave_a))
    if sa > abs(a[i] - ave_a):
        sa = abs(a[i] - ave_a)
        min_ind = i
print(min_ind)

Failing test case input:
4
1 22 12 3

Expected output:
2


Actual output:
8.5
12.5
2.5
6.5
2


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N= int(input())
A= list(map(int,input().split()))

Ave = sum(A)/len(A)

abs_distance = list()

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





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

Failing test case input:
4
2 5 5 5

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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)))
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from statistics import mean
n = int(input())
a = list(map(int, input().split()))

m = mean(a)
Min = abs(a[0]-m)
ret = []

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

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

Failing test case input:
4
-7 1 3 0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=list(map(int, input().split()))
adv=sum(a)
min=10000
ans=0
for i in range(N):
    if min>abs(a[i]-adv):
        min=abs(a[i]-adv)
        ans=i
print(ans)


Failing test case input:
4
-4 1 3 2

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int, input().split()))
adv=sum(a)/N
min=10000
ans=0
for i in range(N):
    if min>abs(a[i]-adv):
        min=abs(a[i]-adv)
        ans=i
print(ans)

Problem: p03214
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
*a,=map(int,input().split())
m=sum(a)/n
print(m)
i=0
s=10**18
for j in range(n):
    if abs(a[j]-m)<s:
        i=j
        s=abs(a[j]-m)
print(i)

Failing test case input:
4
-5 -1 3 2

Expected output:
1


Actual output:
-0.25
1


Fixed submission (verdict: Accepted):
n=int(input())
*a,=map(int,input().split())
m=sum(a)/n
i=0
s=10**18
for j in range(n):
    if abs(a[j]-m)<s:
        i=j
        s=abs(a[j]-m)
print(i)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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 = a[i] * n - s
		ans = i
print(ans)


Failing test case input:
4
0 1 12 9

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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

Failing test case input:
4
3 9 0 5

Expected output:
3


Actual output:

Fixed submission (verdict: Accepted):
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)
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
0 5 6 5

Expected output:
1


Actual output:
3


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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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=Ave-A[i]
        Ans=i

print(Ans)

Failing test case input:
4
-1 13 12 2

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-8 0 4 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N
ans = 0
sa = 10**9
for i in range(N):
    x = max(A[i]-ave,ave-A[i])
    if x < sa:
        sa = x
        ans = i
print(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
1 22 12 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
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)
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    heikin=sum(l)
    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()

Failing test case input:
4
4 4 3 5

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
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()

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

m = sum(a)/n
a1 = list(set(sorted(a)))
a2 = [0]*len(a1)
for i in range(len(a1)):
    a2[i] = abs(m-a1[i])
print(a.index(a1[a2.index(min(a2))]))

Failing test case input:
4
1 19 18 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
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)))

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
n = sum(A) 
A2 = [abs(n - a) for a in A]
min_a = min(A2)
print(A2.index(min_a))


Failing test case input:
4
-5 0 4 -1

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
n = sum(A) / N
A2 = [abs(n - a) for a in A]
min_a = min(A2)
print(A2.index(min_a))

Problem: p03214
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
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)))

Failing test case input:
4
-4 0 1 8

Expected output:
2


Actual output:
[5.25, 1.25, 0.25, 6.75]
2


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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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(int(abs(A[i]-Ave)))
    


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

Failing test case input:
4
-4 0 3 8

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
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)))
Problem: p03214
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)

Failing test case input:
4
0 10 12 1

Expected output:
1


Actual output:
3


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

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
-1 2 12 9

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
1 19 12 3

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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
        tmp = abs(ave - a[i])
print(ans)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)
        print(math.fabs(a[i]-m))

print(ret)

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

Failing test case input:
4
0 20 12 1

Expected output:
2


Actual output:
3.75
[2]
2


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
4
0 19 13 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
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(n):
  if diff>abs(s-a[i]*n): 
    diff= abs(s-a[i]*n)
    ans=i
print(ans)
Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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


Failing test case input:
4
0 1 12 9

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
n= int(input())
a= list(map(int,input().split()))
m=sum(a)/n
for i in range(n):
    a[i]=abs(a[i]-m)
for i in range(n):
    if a[i]==min(a):
        print(i)
        break

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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

print(ans)



Failing test case input:
4
-4 3 4 7

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

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

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

print(ans)



Failing test case input:
4
5 0 2 5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p03214
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
1 19 12 2

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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
        tmp = abs(ave - a[i])
print(ans)

Problem: p03214
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)))

Failing test case input:
4
1 19 12 3

Expected output:
2


Actual output:
[7.75]
[7.75, 10.25]
[7.75, 10.25, 3.25]
[7.75, 10.25, 3.25, 5.75]
2


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