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

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