def main():
    n = int(input())
    a = input().split()
    ans = {}
    ave = 0

    # if n != len(a):
    #     exit()

    for i in a:
        ave += int(i)

    ave = ave / n

    for j in range(n):
        if ave >= int(a[j]):
            ans.update({str(j): ave - int(a[j])})
        else:
            ans.update({str(j): int(a[j]) - ave})

    print(min(ans, key=ans.get))


if __name__ == '__main__':
    main()
