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 + 1).fill('').map((value, selected) => {
  //   return inputs
  //     .map((num, index) => {
  //       console.log(`Math.abs(${num} - (${selected} + ${(index + 1)}))`);
  //       return Math.abs(num - (0 + (index + 1)));
  //     })
  //     .reduce((prev, current) => {
  //       return prev + current;
  //     }, 0);
  // });
  const results = inputs
    .map((num, index) => {
      return Math.abs(num - (0 + (index + 1)));
    })
    .reduce((prev, current) => {
      return prev + current;
    }, 0);
  // console.log(results);
  console.log('%s', Math.min(...results));
}

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