Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func parseToArray2d(lines []string) [][]int64 {
	var result [][]int64
	for _, line := range lines {
		var parsedLine []int64
		for _, element := range strings.Split(line, " ") {
			n, err := strconv.ParseInt(element, 10, 64)
			if err != nil {
				fmt.Printf("Error: element = %v\n", element)
			}
			parsedLine = append(parsedLine, n)
		}
		result = append(result, parsedLine)
	}
	return result
}

func max(l, r int64) int64 {
	if l > r {
		return l
	}
	return r
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	content := []string{}
	for scanner.Scan() {
		line := scanner.Text()
		content = append(content, line)
	}
	arr := parseToArray2d(content)
	input := arr[1]
	sort.Slice(input, func(i, j int) bool { return input[i] < input[j] })

	var costMin int64 = math.MaxInt64
	nMin := input[0]
	nMax := input[len(input)-1]
	for x := nMin; x <= nMax; x++ {
		costCurrent := max(x - nMin, nMax - x)
		if costCurrent < costMin {
			costMin = costCurrent
		}
	}

	fmt.Println(costMin)
}

Python: n = int(input())
a = list(map(int, input().split()))
if (max(a)-min(a)) % 2 == 0:
    print((max(a)-min(a))//2)
else:
    print((max(a)-min(a))//2+1)

Python: n=int(input())
m=list(map(int,input().split()))
s=max(m)
t=min(m)

if (s-t)%2==0:
    print((s-t)//2)
else:
    print((s-t+1)//2)

Python: n=int(input())
a=list(map(int,input().split()))
b=max(a)-min(a)
if b%2:
    b=b+1
    print(b//2)
else:
    print(b//2)

Python: N=int(input())

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

a= max(x) - min(x) +1

print(a//2)

Python: n=int(input())
house=list(map(int,input().split()))

min=10000
for j in range(2001):
    dis=[]
    for i in range(n):
        dis.append(abs(house[i]-j))
    a=max(dis)
    #print(a)
    if min>a:
        min=a
    else:
        pass
print(min)

Python: a = int(input())
b = list(map(int,input().split()))
c = abs(max(b) - min(b))
if c % 2:
  c = c + 1
  print(c // 2)
else:
  print(c // 2)

Python: 
n = int(input())
x = list(map(int,input().split()))

a = max(x)-min(x)

if a%2==0:
    print(a//2)
else:
    a += 1
    print(a//2)

Python: lst=[]
N=int(input())
lst=[int(x) for x in input().split()]
a=max(lst)
b=min(lst)
print(a-((a+b)//2))

Python: n = int(input())
a = list(map(int,input().split()))
if (max(a)-min(a)) % 2 == 0:
    print((max(a)-min(a))//2)
else:
    print((max(a)-min(a))//2+1)

Python: import math
N = int(input())
x = [int(x) for x in input().split()]
print(math.ceil((max(x) - min(x)) / 2))

Python: n = int(input())
X = [int(x) for x in input().split()]

sub = max(X) - min(X)

if sub % 2 == 0 :
    print(sub // 2)
else :
    print(sub // 2 + 1)

Python: input()
x = input() # x = "4 0 2"
list_a = x.split() # list_moji = ["4", "0", "2"]
list_num = []
for i in list_a:
    list_num.append(int(i))
answer = max(list_num) - (min(list_num) + max(list_num))//2
print(answer)

Python: N = int(input())
x = list(map(int, input().split()))
max = max(x)
min = min(x)
if (max - min) % 2 == 0:
    print((max - min) // 2)
else:
    print(((max - min) + 1) // 2)

Python: a=int(input())
lst=list(map(int,input().split()))
b=max(lst)
c=min(lst)
d=(b-c)//2
if (b-c)%2==0:
    print(d)
else:
    print(d+1)

Python: N=int(input())
a = list(map(int,input().split()))
a.sort()
A=(max(a)-min(a)+1)//2
print(A)

Python: N=int(input())
x=list(map(int,input().split()))

s = max(x) - min(x)
if s == 1:
   print("1")
else:
   if s % 2 == 0:
      print(int(s / 2))
   else:
      print(int(s / 2) + 1)

Python: n=int(input())
x=list(map(int,input().split()))
mi=(max(x)+min(x))//2
print(max(x)-mi)

Python: a = int(input())
i = list(map(int, input().split()))


if (max(i)-min(i))%2==0:
    print(int((max(i)-min(i))/2))
if (max(i)-min(i))%2==1:
    print(int((max(i)-min(i)+1)/2))

Python: n=int(input())
l=list(map(int,input().split()))
a=max(l)
b=min(l)
c=(a+b+1)//2
print(abs(b-c))

Python: N = int(input())
lst1 = list(map(int,input().split()))
y = min(lst1)
z = max(lst1)
if (z-y)%2==0:
    print((z-y)//2)
else:
    print((z-y+1)//2)

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

print(max(a)-(max(a)+min(a))//2)

Python: N=int(input())
x=list(map(int,input().split()))
min_x=min(x)
max_x=max(x)
m1=(min_x+max_x)//2
m2=(min_x+max_x+1)//2
print(min([max(max_x-m1,m1-min_x),max(max_x-m2,m2-min_x)]))

Python: N=int(input())

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

a= max(x) - min(x) +1

print(a//2)

Python: # coding: utf-8
# Your code here!

n = int(input())
a = list(map(int,input().split()))
print((max(a)-min(a)+1)//2)

Python: import math
h=int(input())
p=list(map(int,input().split()))
print(math.ceil((max(p)-min(p))/2))

Python: n=int(input())
x=list(map(int,input().split()))
s=max(x)-min(x)
if s%2==0:
    print(int(s/2))
else:
    print(int((s+1)/2))

Python: N = int(input())
a = list(map(int,input().split()))
if (max(a)-min(a))%2 == 0:
    print((max(a)-min(a))//2)
else:
    print(((max(a)-min(a))//2)+1)

Python: # coding: utf-8
# Your code here!
N=int(input())
x=list(map(int,input().split()))

if (max(x)-min(x))%2==0:
    print((max(x)-min(x))//2)
else:
    print((max(x)-min(x))//2+1)

Python: N=int(input())
A=list(map(int,input().split()))
A=sorted(A)


if (A[-1]-A[0])%2==1:
    print((A[-1]-A[0]+1)//2)
else:
    print((A[-1]-A[0])//2)

Python: # coding: utf-8
# Your code here!

N = int(input())
l = list(map(int, input().split()))

s = max(l) - min(l)
if s == 1:
   print("1")
else:
   if s % 2 == 0:
      print(int(s / 2))
   else:
      print(int(s / 2) + 1)

Python: N=int(input())
lst=list(map(int,input().split()))

l=max(lst)-min(lst)
if l==1:
    print(1)
elif l%2==0:
    print(int(l/2))
else:
    print(int((l+1)/2))

Python: n=int(input())
l=list(map(int,input().split()))
    
x=max(l)-min(l)
    
if x==1:
    print("1")
elif x%2==0:
    print(x//2)
else:
    print(x//2+1)

Python: N=int(input())
x=list(map(int,input().split()))

t=max(x)-min(x)
if t%2==0:
    y=int(t/2)
else:
    y=int((t+1)/2)
print(y)

Python: import math

N=int(input())

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

a=((min(i)+max(i))/2)
a=math.ceil(a)

print(a-min(i))

Python: 
N = int(input())
x = [int(i) for i in input().split()]

minX = 9999
maxX = -1

for i in range(N):
    minX = min(minX, x[i])
    maxX = max(maxX, x[i])
    
print((maxX-minX+1)//2)

Python: import math
A = int(input())
B = list(map(int,input().split()))
m = min(B)
M = max(B)
print(math.ceil((m + M) / 2) - m)

Python: n = int(input())
a = sorted([int(s) for s in input().split()])

memory = max([abs(int(p)-a[0]) for p in a])
for i in range(a[0]+1,a[n-1]+1):
    memory1 = max([abs(int(t)-i) for t in a])
    memory = min(memory,memory1)
print(memory)

Python: n = int(input())
lst = list(map(int,input().split()))

lst.sort()

d = (lst[n-1]-lst[0])+1
print(d//2)

Python: N=int(input())
n=list(map(int,input().split()))
if N >= 2:
    a=sorted(n)
    if (a[N-1]-a[0])%2 == 0:
        print((a[N-1]-a[0])//2)
    else:
        print((a[N-1]-a[0]+1)//2)
elif N == 1:
    print(0)

Python: n = int(input())
  
houses = list(map(int,input().split()))

m = max(houses)
n = min(houses)

print((m-n+1)//2)

Python: N = int(input())
x_array = sorted([int(x) for x in input().split()])
dif = int((x_array[-1] + x_array[0])/2)
print(x_array[-1]-dif)

Python: N=int(input())
x=list(map(int,input().split()))
s=max(x)-min(x)
if s%2==0:
    print(int(s/2))
else:
    print(int((s+1)/2))

Python: #0407
N = int(input())
x = list(map(int,input().split()))
x.sort()
a = int(x[0])
b = int(x[N-1])
if a%2 == 0 and b%2 == 0:
    print((b - a)//2)
else:
    print((b - a + 1)//2)

Python: import math
N=int(input())
line=input()
a=[]
t = line.split(" ")
for i in range(0,N):
    a.append(int(t[i]))

A = []
for n in a:
    A.append(n-min(a))
print(math.ceil((max(A)+min(A))/2))

Python: import math
n=int(input())
a=list(map(int,input().split()))
A=max(a)
B=min(a)
C=(math.ceil((A+B)/2))
if abs(A-C) > abs(B-C):
    print(abs(A-C))
elif abs(A-C) < abs(B-C):
    print(abs(B-C))
else:
    print(abs(A-C))