// C: Travelling Plan
// OK
"use strict";

const DEBUG_MODE = false;
const INPUT_LIST_LENGTH_INDEX = 0;
const INPUT_LIST_INDEX = 1;
const INPUT_LIST_DELIMITER = " ";

const inputRaw = DEBUG_MODE
  ? "6\n-679 -2409 -3258 3095 -3291 -4462".split("\n")
  : require("fs")
      .readFileSync("/dev/stdin", "utf8")
      .trim()
      .split("\n");
const inputListLength = parseInt(inputRaw[INPUT_LIST_LENGTH_INDEX]);
const inputList = inputRaw[INPUT_LIST_INDEX].split(INPUT_LIST_DELIMITER).map(
  item => parseInt(item)
);

const process = (inputList, inputListLength) => {
  // memoize!
  let paddedList = [0, ...inputList, 0];

  let totalSteps = 0;

  // index 1 until last the padded 0 suffix
  for (let i = 1; i < inputListLength + 2; i++) {
    totalSteps = totalSteps + Math.abs(paddedList[i] - paddedList[i - 1]);
  }

  // from the total steps,
  // 1. subtract the distance of path to and from the skipped node
  // 2. add the distance from the path before the skipped node to the node after the skipped node
  for (
    let skippedIndex = 1;
    skippedIndex < inputListLength + 1;
    skippedIndex++
  ) {
    // subtracted path is distance(i-1, i) to distance (i, i+1)
    const itemBeforeSkipped = paddedList[skippedIndex - 1];
    const skipped = paddedList[skippedIndex];
    const itemAfterSkipped = paddedList[skippedIndex + 1];

    const pathToSkippedIndex = Math.abs(skipped - itemBeforeSkipped);
    const pathFromSkippedIndex = Math.abs(skipped - itemAfterSkipped);

    const pathToSubtract = Math.abs(pathToSkippedIndex + pathFromSkippedIndex);
    const pathToAdd = Math.abs(itemBeforeSkipped - itemAfterSkipped);

    console.log(totalSteps - pathToSubtract + pathToAdd);
  }
};

process(inputList, inputListLength);
