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

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

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

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

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

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

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

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())
houses = list(map(int,input().split()))
houses.sort()
building = (houses[-1] - houses[0]) / 2 
if type(building) == float:
    building += 0.5
print(int(building))

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

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: #(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()))
Xmn, Xmx = min(X), max(X)
temp = []
res = Xmx-Xmn
for x in range(Xmn, Xmx+1):
	for n in range(N):
		temp.append(abs(X[n]-x))
	if max(temp)<res:
		res = max(temp)
	temp=[]

print(res)

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

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

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

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)+1)//2)

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

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

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

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

Python: N = int(input())
x = [int(i) for i in input().split()]
x.sort()
a = min(x)
b = max(x)
c = b-a
if c > 1:
    print(-(-c//2))
else:
    print(c)

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

print(ans)

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

C++: #include<bits/stdc++.h>
using namespace std;

#define N 2000

int main() {

  int n;
  cin>>n;

  int a, max = 0, min = N;
  for (int i = 0; i < n; i++) {
    cin>>a;
    if (max < a) max = a;
    if (min > a) min = a;
  }

  int dis = (max - min) + 1;
  cout<<dis/2<<endl;

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main(void) {
    int N;cin>>N;
    vector<int> x(N);
    for (int i = 0; i < N; i++) cin>>x[i];
    sort(all(x));
    int tmp = x[0] + x[N-1];
    cout << max(tmp/2 - x[0], x[N-1] - tmp/2) << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& e : a) {
    cin >> e;
  }
  sort(a.begin(), a.end());
  cout << a[n - 1] - (a[0] + a[n - 1]) / 2 << "\n";
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
	double a;
	double c = 0;
	cin >> a;
	vector<int> b(a);
	for (int i = 0;i < a;i++) {
		cin >> b[i];
		c += b[i];
	}
	int x=*max_element(b.begin(), b.end());
	int y=*min_element(b.begin(), b.end());
	if((x+y)%2==0) cout << (x+y)/2 -y<< endl;
	else cout << (x + y+1) / 2-y << endl;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int x[1001];
	cin >> n;
	for (int i = 1;i <= n;i++)cin >> x[i];
	int ans, Ma, Mi;
	ans = Ma = 0;
	Mi = 10000;
	for (int i = 1;i <= n;i++) {
		Ma = max(Ma, x[i]);
		Mi = min(Mi, x[i]);
	}
	ans = abs(Ma - Mi+1)/2;
	cout << ans << endl;

	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    int maxx=-inf,minn=inf;
    rep(i,0,n){
        int p; scanf("%d",&p);
        chmax(maxx,p); chmin(minn,p);
    }
    printf("%d\n",(maxx-minn+1)/2);
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int n, l=9999, r=0;
    cin >> n;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        l = min(l, x);
        r = max(r, x);
    }
    cout << (r-l+1)/2 << endl;
    return 0;
}