'use strict'

function main(input){
    const N = parseInt(input[0])
    const A = input[1].split(' ').map(Number);
    let B = [];
    for(let i=0;i<N;i++){
        B.push(A[i]-i-1);
    }
    B.sort();
    const n = Math.floor(N/2);
    if(N%2){
        console.log(B[n]);
    }else{
        console.log((B[n]+B[n-1])/2);
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'))