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 "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;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int n; cin >> n;
    int a[n]; rep(i,0,n) cin >> a[i];

    int ans = MOD;
    rep(i,0,2001){
        int sum = 0;
        rep(j,0,n){
            sum = max(sum, abs((int)i-a[j]));
        }
        if(sum < ans) ans = sum;
    }
    cout << ans << "\n";
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;
int a[1010];

int abss(int A){
    if(A < 0)return -A;
    return A;
}

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

    return 0;
}

/*

*/

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> xs(n);
  for(int i=0;i<n;i++) cin>>xs[i];
  sort(xs.begin(),xs.end());
  cout<<(xs.back()-xs.front()+1)/2<<endl;
  return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	auto V=vecin(N);
	auto R=minmax_element(ALL(V));
	auto P=((*R.second)+(*R.first))/2;
	out(max((*R.second)-P,(*R.first)-P));
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int>home(N);
    for(int i=0;i<N;i++){
        cin >> home[i];
    }
    sort(home.begin(),home.end());
    int s =(home[0]+home[N-1])/2;
    int ans = 0;
    for(int i=0;i<N;i++){
        if(home[i]<=s && ans<s-home[i]){
            ans = s-home[i];
        }else if(home[i]>=s && ans<home[i]-s){
            ans = home[i]-s;
        }
    }
    cout << ans <<endl;
}