function Main (input) {
  const inputs = input.split(/\s/g).filter((num) => num).map(num => parseInt(num)).slice(1);
  const max = Math.max(...inputs);
  const results = new Array(max).fill('').map((value, selected) => {
    return inputs.map((num, index) => {
      return Math.abs(num - (selected + index + 1));
    }).reduce((prev, current) => prev + current);
  });
  console.log('%s', Math.min(...results));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
