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: #47 集会所 Wrong Answer

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

x_max = max(x)
x_min = min(x)

print((x_max - x_min+1)//2)

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

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

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

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())
x=list(map(int,input().split()))
print((max(x)-min(x)+1)//2)

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

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

Python: import math
a = int(input())
b = list(map(int, input().split()))
c = min(b)
d = max(b)
print(math.ceil((c+d)/2)-c)

Python: N = int(input())
x = list(map(int, input().split()))
xmin, xmax = min(x), max(x)
temp = []
res = xmax-xmin
for i in range(xmin, xmax+1):
	for n in range(N):
		temp.append(abs(x[n]-i))
	if max(temp)<res:
		res = max(temp)
	temp=[]

print(res)

Python: N = int(input())
X = list((int(x) for x in input().split()))
X.sort()

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

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

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

min_x, max_x = xlist[0], xlist[-1]
ans = 10**9
for x in range(2000+1):
    ans = min(ans, max(x - min_x, max_x - x))
print(ans)

Python: import math
n=int(input())
x=list(map(int,input().split()))
s=max(x)
t=min(x)
d=abs(s-t)
print(math.ceil(d/2))

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

Python: 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: x=int(input())
list=list(map(int,input().split()))

if x==1:
    print(0)
else:
    a=sorted(list)
    b=a[0]
    c=a[-1]
    if c-b==1:
        print(1)
    elif b==0:
        if c%2!=0:
            print(c//2+1)
        else:
            print(c//2)
    elif (c-b)%2!=0:
        print((c-b)//2+1)
    else:
        print((c-b)//2)

Python: import math
N=int(input())
M=list(map(int,input().split()))

a=max(M)
b=min(M)

print(math.ceil((a+b)/2)-b)

Python: N = int(input())
a = list(int(x) for x in input().split())
a.sort()
b = []
for i in range(a[0],a[N-1]+1):
  x = max(abs(i - a[0]),abs(i-a[N-1]))
  b.append(x)
print(min(b))

Python: N = int(input())
a = list(map(int,input().split()))
m = min(a)
M = max(a)
k = M-m
if k%2 != 0:
    k+=1
k/=2
print(f'{k:1.0f}')

Python: n, *a = map(int, open(0).read().split())
print((max(a) - min(a) + 1)//2)

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

Python: import math

times = int(input())
lst = list(map(int, input().split(" ")))

print(math.ceil((max(lst) - min(lst)) / 2))

Python: # coding: utf-8
# 47

n = int(input())
I = list(map(int,input().split()))

I.sort()

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

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())
x=list(map(int,input().split()))
mi=(max(x)+min(x))//2
print(max(x)-mi)

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

mintime = 1000000000000

for i in range(2000+1):
    tmpmin = 0
    for j in x:
        tmpmin = max(tmpmin, abs(i-j))
    if tmpmin < mintime:
        mintime = tmpmin
print(mintime)

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

s = (max(house)+min(house))//2

print(max(house)-s)

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

s=max(a)-min(a)

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()))
a=max(lst)-min(lst)
x=(a)//2
if a%2==0:
    print(x)
else:
    print(x+1)

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

Python: 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: import math

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

#print(x)

if (max(x)-min(x))%2==0:
    print(
        math.ceil((max(x)-min(x))/2)
        )
    
elif (max(x)-min(x))%2!=0:
    print(
        math.ceil((max(x)-(min(x)-1))/2)
        )

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

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

Python: # (46)集会所
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())
x=list(map(int,input().split()))
x.sort()
d=int(x[N-1]-x[0])
if d%2==0:
    print(d//2)
else:
    print((d+1)//2)

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

ans = 1000000000000
for p in range(min, max + 1):
  now = 0
  for q in x:
    if now < abs(p - q):
      now = abs(p - q)
  if ans > now:
    ans = now
print(ans)

Python: import math
N = int(input())
b=[]
a = list(map(int,input().split()))
#print('@',a)

x = (min(a)+max(a))//2

#if (min(a)+max(a))%2 == 0:
for i in range(N):
    b.append(abs(x-a[i]))
print("{:.0f}".format(max(b)))

#else:

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

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

Python: import math
n = int(input())
a = list(map(int, input().split()))
x = max(a)
y = min(a)
print(math.ceil((x+y)/2)-y)

Python: n=int(input())
a=list(map(int,input().split()))
print((max(a)-min(a)+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: import math
N = int(input())
A = list(map(int, input().split()))
m = min(A)
M = max(A)
print(math.ceil((m + M) / 2) - m)