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()))
print((max(a)-min(a)+1)//2)

Python: n=int(input())
lis=list(map(int,input().split()))
a=max(lis)
b=min(lis)
x=a-b
y=-(-x//2)
print(y)

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

b = (max(a) - min(a)) / 2
c =(math.ceil(b))
print(c)

Python: 
if __name__ == '__main__':

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

	l = min(B)
	r = max(B)

	ans = r - (l + r ) // 2 
	print(ans)

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

S = max(A)-min(A)

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

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

distance = max(arr) - min(arr)

if distance % 2 == 0:
    print(distance // 2)
else:
    print(distance // 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)

Python: input()
l = [int(i) for i in input().split()]
print(max(l) - (min(l) + max(l))//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())
x=[]
x=list(map(int,input().split()))
list.sort(x)
distance=(x[N-1]-x[0])//2
if N==1:print(0)
else:
    if distance==0:time=1
    elif (x[N-1]-x[0])%2==0:time=distance
    else:time=distance+1
    print(time)

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())
a=list(map(int,input().split()))
min = min(a)
max = max(a)
b=max-min
if b%2!=0:
    b=b+1
b=b//2
print(b)

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

Python: N=int(input())

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


min=a[0]
i=0
for i in range(N):
    if a[i]<min:
        k=0
        k=a[i]
        a[i]=min
        min=k
    i+=1

max=a[0]
i=0
for i in range(N):
    if a[i]>max:
        k=0
        k=a[i]
        a[i]=max
        max=k
    i+=1
    
c=max-min
import math

print(int(math.ceil(c/2)))

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

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

for i in range(N):
    for j in range(N-1,0,-1):
        if xlist[j-1]>xlist[j]:
            xlist[j-1],xlist[j] = xlist[j],xlist[j-1]

if (xlist[N-1]-xlist[0])%2 == 0:
    T = (xlist[N-1]-xlist[0])//2

if (xlist[N-1]-xlist[0])%2 > 0 : 
    T = (xlist[N-1]-xlist[0])/2+0.5

print(int(T))

Python: n=int(input())
x=[int(i) for i in input().split()]
print(max(x)-((min(x)+max(x))//2))

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: 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
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())
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: 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())
s=list(map(int, input().split()))
t=max(s)-min(s)
print((t+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: x=int(input())
a=input().split()
j=0
while j<x :
    a[j]=int(a[j])
    j=j+1
i=0
while i<x :
    k=0
    while k<(x-1) :
        if a[k]>a[k+1] : 
            tmp=a[k]
            a[k]=a[k+1]
            a[k+1]=tmp
        k=k+1
    i=i+1
mx=int(a[x-1])
mn=int(a[0])
if (mx-mn)%2>0 : ans=(mx-mn)//2+1
else : ans=(mx-mn)/2
print(int(ans))

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

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

Python: n = int(input())
data = list(map(int, input().split()))
#print(max(data),min(data))
l = max(data) - min(data)
meet = -(-l //2)
print(meet)

Python: n=int(input())
a=list(map(int,input().split()))
x=max(a)
y=min(a)
w=x-y
if w%2==0:
    print(w//2)
else:
    print(w//2+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: n=int(input())

a=input().split()

for i in range(n):
    a[i]=int(a[i])

mina=min(a)
maxa=max(a)



print((maxa-mina+1)//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: 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())
l=[]
l=list(map(int,input().split()))
l.sort()
a=max(l)
b=min(l)
if (a-b)%2==0:
    print(int((a-b)/2))
else:
    print(int((a-b+1)/2))

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

print(int(c))

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

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

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

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

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

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


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

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

c=max(b)
d=min(b)

if (c-d)%2==0:
    print((c-d)//2)
else:
    print((c-d+1)//2)

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 = int(input())

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


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

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