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)
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N; cin >> N;
    int x[1100];
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    sort(x,x+N);
    cout << (x[N-1]-x[0]+1)/2 << endl;
}

C++: #include <iostream>
using namespace std;

int n, mx = 0, mn = 2000;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;

		if (x > mx)
			mx = x;

		if (x < mn)
			mn = x;
	}

	cout << (mx - mn + 1) / 2 << endl;	

	return 0;
}

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

int main(){
    int n;
    cin >> n;

    vector<int> x(n);

    for(int i=0;i<n;i++){
        cin >> x[i];
    }

    sort(x.begin(),x.end());

    int max = x[n-1];
    int min = x[0];

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

}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>
#include <cstdio>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;

void solve(){
  cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;i++)cin >> x[i];
  int mx=*max_element(x.begin(),x.end());
  int mn=*min_element(x.begin(),x.end());
  int ans=10000;
  int t,tmp;
  for(int i=mn;i<=mx;i++){
    t=0;
    tmp=-1;
    for(int j=0;j<n;j++){
      t=abs(i-x[j]);
      tmp=max(t,tmp);
    }
    ans=min(ans,tmp);
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

C++: #include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>

#define	rep(i, n) for(int i=0; i<n; i++)

#define P pair<int, int>

typedef long long ll;

using namespace std;

#include <string>
#include <cctype>
typedef string::const_iterator State;
class ParseError {};


int main() {
	int N;
	cin >> N;
	int h[1005];
	rep(i, N) cin >> h[i];
	sort(h, h + N);
	int mid = (h[0] + h[N - 1]) / 2;
	cout << max(mid - h[0], h[N - 1] - mid) << endl;

	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int n;
  cin>>n;
  int x;
  int max=0,min=2000;
  for(int i=0;i<n;i++){
    cin>>x;
    if(x<min)min=x;
    if(x>max)max=x;
  }
  x=(min+max)/2;
  int ans=max-x;
  cout<<ans<<endl;
  return 0;
  
}

C++: #include <stdio.h>

int main(void)
{
	int n,x,min,max,i;
	scanf("%d",&n);
	scanf("%d",&x);
	min=x;
	max=x;
	for(i=1;i<n;i++){
		scanf("%d",&x);
		if(min>x){
			min=x;
		}
		if(max<x){
			max=x;
		}
	}
	printf("%d\n",(max-min+1)/2);
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {
	int n, k[1005];
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	sort(k, k + n);
	cout << (k[n - 1] - k[0] + 1) / 2 << endl;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;

//集会所
int main() {
    int n;
    cin >> n;
    vector<int> x(n,0);
    rep(i,n)cin >> x[i];
    sort(x.begin(),x.end());
    int res = INF;
    rep(i,x[n-1]+1){
        int time = 0;
        rep(j,n){
            time = max(abs(x[j]-i),time);
        }
        res = min(time,res);
    }
    cout << res << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

C++: #include <stdio.h>

int main(void)
{
	int N,i,x[1000],max=0,min,a;
	scanf("%d",&N);
	for (i=1;i<=N;i++){
		scanf("%d",&x[i]);
		if(max<x[i]){
			max=x[i];
		}
		if(min>x[i]){
			min=x[i];
		}
	}
	a=(max-min+1)/2;
	printf("%d\n",a);
	return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, ma = MINF, mi = INF;
int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		ma = max(ma, a);
		mi = min(mi, a);
	}
	cout << (ma - mi + 1) / 2 << endl;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> x(N);
int i;
for(i=0;i<N;i++)cin >> x[i];
sort(x.begin(),x.end());
cout << (x[N-1]-x[0]+1)/2 << endl;
}

C++: #include<stdio.h>
int main(){
  int N,x[2000],i,j,dis,dismax=0,ex=2000;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&x[i]);
  }
  for(i=0;i<=2000;i++){
    for(j=0;j<N;j++){
      dis=i-x[j];
      if(dis<0)dis*=-1;
      if(dis>dismax)dismax=dis;
    }
    if(ex<dismax)break;
    ex=dismax;
    dismax=0;
  }
  printf("%d\n",ex);
  return 0;
}