s = input()
w = input().split()
for i in range(int(s)):
  sum += int(w[i])
average = sum / int(s)
for i in range(int(s)):
    if abs(int(w[i]) - average) < limit:
        limit = abs(int(w[i]) - average)
print(limit)
