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