Go: package main

import (
    "bufio"
    "fmt"
    "strconv"
    "os"
    "strings"
    "math"
)

/*
var sc = bufio.NewScanner(os.Stdin) exceed MaxScanTokenSize
func read() string {
    sc.Scan()
    return sc.Text()
}
*/

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

func toInt(str string) int {
    n, _ := strconv.Atoi(str)
    return n
}

func min(a int, b int) int {
    return int(math.Min(float64(a), float64(b)))
}

func max(a int, b int) int {
    return int(math.Max(float64(a), float64(b)))
}

func main() {
    nm := strings.Split(readLine(), " ")
    n := toInt(nm[0])
    var infoDist [100000]int
    for i := 0; i < n; i++ {
        infoDist[i] = 100000
    }
    haveInfo := strings.Split(readLine(), " ")
    for _, value := range haveInfo {
        infoDist[toInt(value) - 1] = 0
    }

    for i := 0;i < n - 1; i++ {
        infoDist[i + 1] = min(infoDist[i] + 1, infoDist[i + 1])
    }

    for i := n - 1;i > 0; i-- {
        infoDist[i - 1] = min(infoDist[i] + 1, infoDist[i - 1])
    }

    ans := 0
    for i := 0;i < n;i++ {
        ans = max(ans, infoDist[i])
    }

    fmt.Println(max(ans, infoDist[0]))

}

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

int n;
int m;
int a[100000];
int b;
int ans = 0;

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

	for (int i = 0; i < m + 1; i++){
		if (i == 0){
			b = a[i] - 1;
		} else if (i == m){
			b = n - a[i];
		}
		else{
			b = a[i + 1] - a[i] - 1;
			if (b % 2 == 0){
				b /= 2;
			}
			else{
				b--;
				b /= 2;
			}
		}

		ans = max(b, ans);
	}

	cout << ans << endl;
		
	return 0;
}

C++: #include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,m;
    cin >> n >> m;
    int dif = 0;
    vector<int>v(m);
    rep(i,m)cin >> v[i];
    if(m == 1){
        return cout << max(v.front() - 1 , n - v.front()) << endl, 0;
    }
    rep(i,v.size()){
        int a = v[i] - (i?v[i-1]:1);
        int b = (i+1 != v.size() ? v[i+1]:n)- v[i];
        if(i == 0)a=a*2;
        if(i+1 == v.size())b=b*2;
        cmax(dif,max((a/2),(b/2)));
      
    }
    cout << dif << endl;
}

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

int main() {
	int N, M; cin >> N >> M;
	vector<int>v;
	for (int i = 0; i < M; ++i) {
		int a; cin >> a;
		v.emplace_back(a);
	}
	int ans = 0;
	ans = max(ans, v[0] - 1);
	ans = max(ans, N - v.back());
	for (int i = 0; i < M-1; ++i) {
		ans = max(ans, (v[i + 1] - v[i]) / 2);
	}
	cout << ans << endl;
	return 0;
}

C++: /*
	suffix array
	sa[i]= i??????????°???????suffix???????????????index (sa[0]=N)
	_k,_N?????°????????????????????£?????????(compare???2?????°???????????????)

	RMQ??¨????????° s?????§????????????t?????????????????´??? ???????????????????????????(jag2014summerday4F)

	lcp[i]= len of common prefix of s[sa[i]..],s[sa[i+1]..]
	????§????RMQ???????????°?????????substring???common prefix?????????????????????
*/
const int MAX_N=;
int _k,_N,_rank[MAX_N+1],tmp[MAX_N+1],sa[MAX_N+1],lcp[MAX_N];
bool compare_sa(int i,int j){
	if(_rank[i]!=_rank[j]) return _rank[i]<_rank[j];
	else{
		int ri= i+_k<=_N ? _rank[i+_k] : -1;
		int rj= j+_k<=_N ? _rank[j+_k] : -1;
		return ri<rj;
	}
}
void make_sa(string s){		//(string s,int *sa)
	_N=s.length();
	rep(i,_N+1){
		sa[i]=i;
		_rank[i]= i<_N?s[i]:-1;
	}
	for(_k=1;_k<=_N;_k*=2){
		sort(sa,sa+_N+1,compare_sa);
		tmp[sa[0]]=0;
		rep1(i,_N){
			tmp[sa[i]]=tmp[sa[i-1]]+( compare_sa(sa[i-1],sa[i]) ? 1 : 0 );
		}
		rep(i,_N+1) _rank[i]=tmp[i];
	}
}
void make_lcp(string s){
	int N=s.length();
	rep(i,N+1) _rank[sa[i]]=i;
	int h=0;
	lcp[0]=0;
	rep(i,N){
		int j=sa[_rank[i]-1];
		if(h>0) h--;
		for(;j+h<N&&i+h<N;h++){
			if(s[j+h]!=s[i+h]) break;
		}
		lcp[_rank[i]-1]=h;
	}
}

C++: #include <iostream>

using namespace std;

int N,M;
const int MAX_N = 100010;
const int INF = 1 << 20;
int A[MAX_N];
int Left[MAX_N];
int Right[MAX_N];
int main(){
  cin >> N >> M;
  int result = 0;

  for (int i = 0; i < M; i++){
    int x;
    cin >> x;
    x--;
    A[x]++;
  }
  int tmp = INF;
  for (int i = 0; i < N; i++){

    if (A[i]){
      tmp = 0;
    }
    Left[i] = tmp;    
    tmp++;
  }
  tmp = INF;
  for (int i = N - 1; i >= 0; i--){
   
    if (A[i]){
      tmp = 0;
    }
    Right[i] = tmp;    
    tmp++;
  }
  int res = 0;
  for (int i = 0; i < N; i++){
    res = max(res, min(Left[i], Right[i]));
  }
  cout << res << endl;
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n, m;
  int a, last_a;
  int max_diff = 0;
  int diff;

  cin >> n >> m;

  cin >> a;
  last_a = a;
  max_diff = a -1;

  for (int i = 1; i < m; i++) {
    cin >> a;
    diff = a - last_a - 1;
    !(diff % 2) ? diff /= 2 : diff = diff / 2 + 1;
    if (diff > max_diff) max_diff = diff;
    last_a = a;
  }

  if (n - a > max_diff) max_diff = n - a;

  cout << max_diff << endl;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 1000000
using namespace std;

int main(){
    int n,m,a=0,b=0;
    cin>>n>>m;
    int ans=0;
    cin>>a;
    int z=a;
    b=a;
    rep(i,1,m){
        cin>>a;
        ans=max(a-b,ans);
        //cout<<ans<<endl;
        b=a;
    }
    //cout<<ans<<endl;
    if(ans/2<n-a&&z-1<n-a){
        cout<<n-a<<endl;
    }else{
        cout<<max(ans/2,z-1)<<endl;
    }
    return 0;
}

C++: //	created : 16/03/14
// 	author   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF 1e9

bool ok(ll t,int n,int m,vector<ll> x){
	ll p = 0;
	rep(i,m){
		if(p < x[i]){
			if( x[i] - p > t ){
				return false;
			}
			p = max(	x[i] + (t - 2 * (x[i] - p)) + 1,
						x[i] + (t - (x[i] - p)) / 2 + 1);
		} else {
			p = max(p,x[i] + t + 1);
		}

		if( p >= n){
			return true;
		}
	}
	return false;
}

int main(void){
	int n,m;
	cin>>n>>m;
	vector<ll> x(m);
	rep(i,m){
		cin>>x[i];
		x[i]--;
	}

	if(n==m){
		cout<<0<<endl;
		return 0;
	}

	ll l = 0;
	ll r = 3e9;

	while(r - l > 1){
		ll mid = (r+l) / 2;
		if(ok(mid,n,m,x)){
			r = mid;
		}else{
			l = mid;
		}
	}

	cout<<r<<endl;
}