Go: package main

import "fmt"

func main() {
	var n, x int
	fmt.Scanln(&n)
	min, max := 2000, 0
	for ; n > 0; n-- {
		fmt.Scan(&x)
		if x < min {
			min = x
		}
		if x > max {
			max = x
		}
	}
	fmt.Println((max - min + 1) / 2)
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, sum = 0, num = 2001; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a; sum = max(sum, a); num = min(num, a);
	}
	cout << max(sum - (abs(sum - num) / 2 + min(sum, num)), num - (abs(sum - num) / 2 + min(sum, num))) << endl;
	cin >> n;
}

C++: #include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	ll n, le=2021, ri=0, i;
	
	cin>>n;
	
	vector <ll> a(n+1);
	
	for(i=1;i<=n;i++){
		cin>>a[i];
		le=min(le, a[i]);
		ri=max(ri, a[i]);
	}
	
	ri=ri-le;
	le=0;
	
	
	cout<<(ri+le)/2+(ri+le)%2<<"\n";
}

C++: #include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int N,x,syu=0,xmax=0,xmin=2000;
int main(void)
{
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>x;
		if(x<xmin){
			xmin=x;
		}
		if(x>xmax){
			xmax=x;
		}
	}
	syu+=(double)0.5+(xmax-xmin)/2.0;
	cout<<syu<<endl;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	cout << a[n-1]-(a[0]+a[n-1])/2 << endl;
}

C++: #include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

void Solve(){
    UL n; cin >> n;
    UL x[1000]; rep(i, n) cin >> x[i];
    sort(x, x+n);
    cout << (x[n-1] - x[0] + 1) / 2 << endl;
}

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

C++: #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int updivide(int a,int b){
    if(b==1) return a;
    else if(a%b==0) return a/b;
    else return (a/b)+1;
}

int main(){
    int n;
    in(n);
    vector<int> vec(n);
    in(vec);
    sort(all(vec));
    out(updivide(vec[n-1]-vec[0],2));
}

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

int main() {
	long long N, X[2000];
	cin >> N;
	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 <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) {
        cin >> x.at(i);
    }
    int shuukai = (*max_element(x.begin(), x.end())+*min_element(x.begin(), x.end()))/2;
    int longest = 0;
    rep(i,n) {
        int time = abs(shuukai-x.at(i));
        if (time > longest) {
            longest = time;
        }
    }
    cout << longest << endl;
}