jiahuimbzuai/CoQuIR huggingface dataset:
//  [swift]
    solve()
    func solve() {
        let AV = readLine()!.split(separator: " ")
        let A = Int64(AV[0])!
        let V = Int64(AV[1])!
        let BW = readLine()!.split(separator: " ")
        let B = Int64(BW[0])!
        let W = Int64(BW[1])!
        let T = Int64(readLine()!)!

        let diff = abs(B - A)
        let diffPerSec = V - W
        if A == B {
            print("YES")
            return
        }
        if diffPerSec <= 0  {
            print("NO")
            return
        }

        if diff <= diffPerSec * T {
            print("YES")
        } else {
            print("NO")
        }
    }
//  [swift]
import Foundation

let (a, v) = readInts().mapToTuple()
let (b, w) = readInts().mapToTuple()
let t = Int(readLine()!)!

print(abs(a - b) <= (v - w) * t ? "YES" : "NO")



func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }

    subscript(gen: Index) -> Element {
        _modify { yield &self[index(gen, offsetBy: -1)] }
        _read   { yield self[index(gen, offsetBy: -1)] }
    }
}
//  [swift]
import Foundation

var line = readLine()!.components(separatedBy: " ").map { Decimal(string: $0)! }
let A = line[0]
let V = line[1]
line = readLine()!.components(separatedBy: " ").map { Decimal(string: $0)! }
let B = line[0]
let W = line[1]
let T = readLine()!.components(separatedBy: " ").map { Decimal(string: $0)! }.first!

if abs(B - A) <= (V - W) * T {
    print("YES")
} else {
    print("NO")
}
//  [swift]
import Foundation

let inputOni = readLine()!.components(separatedBy: " ").map{ Int($0)}
let inputNige = readLine()!.components(separatedBy: " ").map{ Int($0)}
let T = Int(readLine()!)!

let A = inputOni[0]!
let V = inputOni[1]!
let B = inputNige[0]!
let W = inputNige[1]!
let dis = abs(A - B)
let disPerSec = (V - W) * T

if dis <= disPerSec {
    print("YES")
}else {
    print("NO")
}
//  [swift]
func readIntPair() -> (Int, Int) {
    let line = readLine()!.split(separator: " ").map({Int($0)!})
    return (line[0], line[1])
}

let (A, V) = readIntPair()
let (B, W) = readIntPair()
let T = Int(readLine()!)!

print(((V - W) * T < max(A, B) - min(A, B)) ? "NO" : "YES")
//  [typescript]
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [a, v]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const [b, w]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const [t]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    return `${Math.abs(a - b) + w * t <= v * t ? 'YES' : 'NO'}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [a, av] = r.nn()
    const [b, bv] = r.nn()
    const [T] = r.nn()

    const d = Math.abs(a - b)
    const vd = av - bv

    if (vd <= 0) return 'NO'
    // 5 3
    return d / vd <= T ? 'YES' : 'NO'
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}
//  [python]
def main():
    N = int(input())
    A = [0] + [int(i) for i in input().split()] + [0]
    l = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
    num = sum(l)
    print("\n".join(
        [str(num - l[i] - l[i + 1] + abs(A[i] - A[i + 2]))
         for i in range(N)]))

    return


main()
//  [python]
def main():
    N = int(input())
    A = [0] + [int(i) for i in input().split()] + [0]
    d = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
    num = sum(d)
    print("\n".join(
        [str(num - d[i] - d[i + 1] + abs(A[i] - A[i + 2]))
         for i in range(N)]))

    return


main()
//  [python]
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
cn = [abs(a[i+1] - a[i]) for i in range(n+1)]
ct = sum(cn)
cs = [ct - cn[i] - cn[i+1] + abs(a[i] - a[i+2]) for i in range(n)]
print('\n'.join(map(str, cs)))
//  [python]
import numpy as np
N = int(input())
A = np.array(["0"] + input().split() + ["0"], dtype=np.int64)
B = np.abs(A[1:] - A[:-1])
C = np.abs(A[2:] - A[:-2])
total = B.sum()
for i in range(N):
    print(total - B[i:i + 2].sum() + C[i])
//  [python]
import numpy as np

n = int(input())

a = list(map(int, input().split(" ")))

yen = 0
x = 0
for i in a:
    yen += abs(i - x)
    x = i
yen += abs(x)

for i in range(n):
    if(i == 0):
        if((0 <= a[i] and a[i] <= a[i+1]) or (0 >= a[i] and a[i] >= a[i+1])):
            print(yen)
        elif(a[i] * a[i+1] < 0):
            print(yen - abs(a[i] * 2))
        elif(a[i] >= a[i+1] or a[i] <= a[i+1]):
            print(yen - abs(a[i+1] -a[i]) * 2)
        else:
            print(yen - abs(a[i] * 2))
    elif(i+1 < n):
        if((a[i-1] <= a[i] and a[i] <= a[i+1]) or (a[i-1] >= a[i] and a[i] >= a[i+1])):
            print(yen)
        elif((a[i-1] >= a[i] and a[i-1] >= a[i+1]) or (a[i-1] <= a[i] and a[i-1] <= a[i+1])):
            print(yen - abs((a[i+1] - a[i]) * 2))
        else:
            print(yen - abs((a[i] - a[i-1]) * 2))
    else:
        if((a[i-1] <= a[i] and a[i] <= 0) or (a[i-1] >= a[i] and a[i] >= 0)):
            print(yen)
        elif(a[i-1] * a[i] < 0):
            print(yen - abs(a[i] * 2))
        else:
            print(yen - abs((a[i-1] - a[i]) * 2))
        break
//  [python]
from collections import deque
import numpy as np

n = int(input())
a = deque(map(int, input().split()))
a.appendleft(0)
a.append(0)
a = np.array(a)

sum = sum([abs(a[i + 1] - a[i]) for i in range(len(a) - 1)])
ans = 0

for i in range(n):
    ans = sum
    ans = ans - abs(a[i + 1] - a[i]) - abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i])
    print(ans)
//  [java]
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] dist = new int[n + 10];
		int[] spot = new int[n + 10];
		long sumDist = 0;
		for(int i = 1; i <= n; i ++) {
			spot[i] = sc.nextInt();
			dist[i] = Math.abs(spot[i] - spot[i - 1]);
			sumDist += dist[i];
		}
		dist[n + 1] = Math.abs(spot[n]);
		sumDist += dist[n + 1];
		
		for(int i = 1; i <=n; i++) {
			int newDist = Math.abs(spot[i - 1] - spot[i + 1]);
			long ans = sumDist - dist[i] - dist[i + 1] + newDist;
			out.println(ans);
		}

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[n + 2];
			a[0] = a[n + 1] = 0;
			IntStream.rangeClosed(1, n).forEach(i -> a[i] = scanner.nextInt());
			int sum = IntStream.rangeClosed(0, n).map(i -> Math.abs(a[i] - a[i + 1])).sum();
			IntStream.rangeClosed(1, n).map(
					i -> sum - Math.abs(a[i] - a[i - 1]) - Math.abs(a[i] - a[i + 1]) + Math.abs(a[i - 1] - a[i + 1]))
					.forEach(System.out::println);
		}
	}
}
//  [java]
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+2];
        A[0] = 0;
        A[N+1] = 0;
        int sum = 0;
        int[][] diff = new int[N+1][2];
        for(int i = 1; i <= N; i++){
            A[i] = sc.nextInt();
            diff[i-1][0] = Math.abs(A[i-1] - A[i]);
            sum += diff[i-1][0];
            if(diff[i-1][0] !=0) diff[i-1][1] = A[i-1] - A[i] <0 ? -1: 1;
        }
        diff[N][0] = Math.abs(A[N]);
        sum += diff[N][0];
        if(diff[N][0] !=0) diff[N][1] = A[N] <0 ? -1: 1;
        for(int i = 1; i <= N; i++){
            if(diff[i-1][1] * diff[i][1] >-1 ) System.out.println(sum);
            else System.out.println(sum - 2*Math.min(diff[i-1][0], diff[i][0]));
        }
        sc.close();
    }

}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] diff = new int[n + 1];
		int sum = 0, pre = 0;

		for (int i = 0; i < n; i++) {
			// 観光地の座標を格納
			a[i] = sc.nextInt();
			// 前の観光地からの費用を計算
			int d = pre - a[i];
			// 前の観光地からの費用を合計に加算
			sum += Math.abs(d);
			diff[i] = d;
			pre = a[i];
		}
		sum += Math.abs(a[n - 1]);
		diff[n] = a[n - 1];
		
		for (int i = 0; i < n; i++) {
			if ((diff[i] < 0 && diff[i + 1] < 0) || (diff[i] > 0 && diff[i + 1] > 0)) {
				System.out.println(sum);
			} else {
				if (Math.abs(diff[i]) <= Math.abs(diff[i + 1])) {
					System.out.println((sum - Math.abs(diff[i] * 2)));
				} else {
					System.out.println((sum - Math.abs(diff[i + 1] * 2)));
				}
			}
		}
		
		sc.close();
	}
}
//  [cpp]
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[100002];
int main(){
  int i, r, s=0;
  rd(N);N += (2);
  for(i=(1);i<(N-1);i++){
    rd(A[i]);
  }
  for(i=(1);i<(N);i++){
    s += abs(A[i]-A[i-1]);
  }
  for(i=(1);i<(N-1);i++){
    r = s;
    if(A[i] <min_L(A[i-1], A[i+1])){
      r -= 2* (min_L(A[i-1], A[i+1])- A[i]);
    }
    if(A[i] >max_L(A[i-1], A[i+1])){
      r -= 2* (A[i] -max_L(A[i-1], A[i+1]));
    }
    wt_L(r);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, A[100002];
// {
//   int i, s = 0, r;
//   rd(N++++);
//   rep(i,1,N-1) rd(A[i]);
//   rep(i,1,N) s += abs(A[i]-A[i-1]);
//   rep(i,1,N-1){
//     r = s;
//     if(A[i] < min(A[i-1], A[i+1])) r -= 2 (min(A[i-1], A[i+1]) - A[i]);
//     if(A[i] > max(A[i-1], A[i+1])) r -= 2 (A[i] - max(A[i-1], A[i+1]));
//     wt(r);
//   }
// }
//  [cpp]
#include <iostream>
#include <cmath>

inline void fastscan(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { count++; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}
 
int main(){
    
    int N; fastscan(N);
    int v[N];
    for (int i = 0; i < N; ++i) fastscan(v[i]);
    int sum = 0;
 
    for (int i = 1; i < N; ++i) sum += abs(v[i - 1] - v[i]);
    sum = sum + abs(0 - v[0]) + abs(v[N - 1] - 0);
    int diff[N];
    diff[0] = abs(0 - v[0]) + abs(v[0] - v[1]) - abs(0 - v[1]);
    for (int i = 1; i < N - 1; ++i){
        diff[i] = abs(v[i - 1] - v[i]) + abs(v[i] - v[i + 1]) - abs(v[i - 1] - v[i + 1]);
    }
    diff[N - 1] = abs(v[N - 2] - v[N - 1]) + abs(v[N - 1] - 0) - abs(v[N - 2] - 0);

    for (int i = 0; i < N; ++i){
        fastout(sum - diff[i]); putchar_unlocked('\n');
    }
    return 0;
}
//  [cpp]
#pragma GCC target("avx")
#pragma GCC optimize ("Ofast")
#include <iostream>
#include <cmath>

char in[1<<21];
char const*o;

inline void init_in() { 
  o = in; 
  in[fread(in,1,sizeof(in)-4,stdin)] = 0;
}

int readInt(){ 
  unsigned u = 0, s = 0;
  while(*o && *o <= 32){
    ++o; 
  }
  if (*o == '-'){
    s = ~s, ++o;
  } else if (*o == '+'){
    ++o;
  }
   
  while(*o>='0' && *o<='9'){
    u = (u<<3) + (u << 1) + (*o++ - '0');
  }

  return static_cast<int>((u^s) + !!s) ;
}

template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) { 
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}
 
int main(){ 
    init_in();
    int N = readInt();
    int v[N];
    for (int i = 0; i < N; ++i) v[i] = readInt();
    int sum = 0;
 
    for (int i = 1; i < N; ++i) sum += abs(v[i - 1] - v[i]);
    sum += abs(0 - v[0]) + abs(v[N - 1]);
    int diff[N]; 
    diff[0] = abs(0 - v[0]) + abs(v[0] - v[1]) - abs(0 - v[1]);
    for (int i = 1; i < N - 1; ++i){
        diff[i] = abs(v[i - 1] - v[i]) + abs(v[i] - v[i + 1]) - abs(v[i - 1] - v[i + 1]);
    }
    diff[N - 1] = abs(v[N - 2] - v[N - 1]) + abs(v[N - 1]) - abs(v[N - 2]);
 
    for (int i = 0; i < N; ++i){
        int ans = sum - diff[i];
        fastout(ans);
    }
    return 0;
}
//  [cpp]
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/


//BinaryIndexTree(siz):長さsizで初期化
//sum(k):区間[0,k]の和を求める
//add(k,x):要素kにxを加える

template<typename T>
struct BinaryIndexTree {

	int n;
	vector<T> data;
	
	BinaryIndexTree(int siz)
	{
		n = siz;
		//1-indexなので配列は1つ多めに用意する
		data.resize(siz + 1, 0);
	}


	T sum(int k) {

		//[0,k)までの和を計算
		T ret = 0;
		while (k > 0) {
			ret += data[k - 1];
			k -= k & -k;
		}
		return ret;
	}

	//0-index
	void add(int k, int x)
	{
		//a_kにxを加算する
		while (k <= n) {
			data[k - 1] += x;
			k += k & -k;
		}
	}


	// bitに入ってる中でx番目に小さい数を求める
	// 1番小さい数はx = 1;
	// bitに3を入れる→add(3, 1), 3を出す→add(3, -1)
	// return == nの場合x個も入っていない
	ll min_xth(int x) {
		int left = -1, right = n;
		while (left + 1 < right) {
			int mid = (left + right) / 2;
			int temp = sum(mid + 1);
			if (temp < x) {
				left = mid;
			}
			else {
				right = mid;
			}
		}
		return right;
	}


	// pを順番通りにするための交換回数
	ll bubble(vector<T> p) {
		int n = p.size();
		ll ans = 0;
		for (int j = 0; j < n; j++) {
			ans += (j - sum(p[j] + 1));
			add(p[j], 1);
		}
		return ans;
	}


};


int main() {

	int n;
	cin >> n;
	vector<int> a;
	a.push_back(0);

	ll sum = 0;

	for (int i = 0; i < n; i++)
	{
		int c;
		cin >> c;
		a.push_back(c);
	}

	

	a.push_back(0);
	for (int i = 0; i <= n; i++)
	{
		sum += abs(a[(i + 1) % (n+2)] - a[i]);
	}

	cerr <<"sum= " <<  sum << endl;

	for (int i = 1; i <= n; i++)
	{
		cerr << abs(a[(i + 1) % (n + 2)] - a[i]) << " " << abs(a[i] - a[(i + n+2 - 1) % (n + 2)]) << " " << abs(a[(i + 1) % (n + 2)] - a[(i + n+2 - 1) % (n + 2)]) << endl;
		cout << sum - abs(a[(i + 1) % (n+2)] - a[i]) - abs(a[i] - a[(i + n+2 - 1) % (n+2)]) + abs(a[(i + 1) % (n+2)] - a[(i + n+2 - 1) % (n+2)]) << endl;
	}


	return 0;
}
//  [cpp]
#include<iostream>
#include<cmath>
#include<cstdlib>
#define ll long long
using namespace std;

int main(){
  int n,a[100002];
  ll max_ans = 0ll,ans = 0ll;

  cin >> n;
  for(int i = 0; i < n+2; i++){
    if(i == 0 or i == n+1) a[i] = 0;
    else cin >> a[i];
    max_ans += abs(a[i] - a[i-1]);
  }

  for(int i = 1; i < n+1; i++){
    if(a[i-1] <= a[i] and a[i] <= a[i+1]){
      cout << max_ans << endl;
    }
    else if(a[i-1] >= a[i] and a[i] >= a[i+1]){
      cout << max_ans << endl;
    }
    else{
      ans = max_ans - (abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]) - abs(a[i+1] - a[i-1]));
      cout << ans << endl;
    }
  }

  return 0;
}
//  [cpp]
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
    bool ret = true;
    if (x < 2) {
        ret = false;
    }
    for (LL i = 2; i <= sqrt(x); i++) {
        if (x%i == 0) {
            ret = false;
        }
    }
    return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    VI a(n+3,0),r(n+3,0);

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        r[i] += r[i-1] + abs(a[i-1] - a[i]);
        dump(r[i]);
    }
    a[n+1] = 0;
    r[n+1] += r[n] + abs(a[n] - a[n+1]);
        for (int i = 1; i <= n; i++) {
            cout << r[i-1] + r[n+1] - r[i+1] + abs(a[i-1] - a[i+1]) << endl;
        }
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,A[100005],sum,charge,i,j;
  char str[600000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  A[0]=0;
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  A[1]=atoi(p);
  for(i=2;i<=N;i++){
   p=strtok(NULL," \n");
   A[i]=atoi(p);
  }
  for(i=1;i<=N;i++){
    sum+=abs(A[i]-A[i-1]);
  }
  sum+=abs(A[N]-A[0]);
  
  for(i=1;i<=N;i++){
    charge=sum;
    if(i==N){
     charge=charge-abs(A[N]-A[N-1])-abs(A[N]-A[0])+abs(A[N-1]-A[0]);
      printf("%d\n",charge);
      break;
    }
   charge-=abs(A[i]-A[i-1]),charge-=abs(A[i+1]-A[i]);
    charge+=abs(A[i+1]-A[i-1]);
    printf("%d\n",charge);
  }
  
  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,i,max=0;
  scanf("%d",&n);
  int a[n+2];
  a[0]=0;
  a[n+1]=0;
  for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<=n;i++)
    max+=abs(a[i+1]-a[i]);
  for(i=1;i<=n;i++)
    printf("%d\n",max-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
  return 0;
}
//  [c]
#include <math.h>
#include <stdio.h>
int main() {
	int n, a[100002], sum = 0;
	scanf("%d", &n);
	a[0] = a[n + 1] = 0;
	for (int i = 1; i <= n + 1; i++) {
		if (i != n + 1) scanf("%d", &a[i]);
		sum += abs(a[i] - a[i - 1]);
	}
	for (int i = 1; i <= n; i++) {
		printf("%d\n", sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) +
						   abs(a[i + 1] - a[i - 1]));
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    int A[N];
    int d = 0;

    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }

    d = abs(A[0]) + abs(A[N-1]);

    for(int i = 1; i < N; i++){
        d += abs(A[i] - A[i-1]);
    }

    if((0 <= A[0] && A[0] <= A[1]) || (A[1] <= A[0] && A[0] <= 0)){
        printf("%d\n", d);
    }else{
        printf("%d\n", d - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]));
    }

    for(int i = 1; i < N-1; i++){
        if((A[i-1] <= A[i] && A[i] <= A[i+1]) || (A[i+1] <= A[i] && A[i] <= A[i-1])){
            printf("%d\n", d);
        }else{
            printf("%d\n", d - abs(A[i]-A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]));
        }
    }

    if((0 <= A[N-1] && A[N-1] <= A[N-2]) || (A[N-2] <= A[N-1] && A[N-1] <= 0)){
        printf("%d\n", d);
    }else{
        printf("%d\n", d - abs(A[N-1]) - abs(A[N-1] - A[N-2]) + abs(A[N-2]));
    }

    return 0;
}
//  [c]
#include<stdio.h>
int b(int x){return x<0?-x:x;}
int main(){
  int a[100002]={0},i,n,c=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){scanf("%d",&a[i]);c+=b(a[i]-a[i-1]);}
  c+=b(a[n+1]-a[n]);
  for(i=1;i<=n;i++)printf("%d\n",c-b(a[i]-a[i-1])-b(a[i+1]-a[i])+b(a[i+1]-a[i-1]));
}
//  [c]
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部変数
static int si1Array[D_ARRAY_MAX + 5];							// 配列
static int siACnt;												// 配列数
static int siSum;												// 取りやめない時の合計値

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 観光スポット数取得
	int liCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liCnt);

	// 配列取得
	si1Array[0] = 0;
	si1Array[liCnt + 1] = 0;
	for (i = 1; i <= liCnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%d", &si1Array[i]);
#else
		fscanf(stdin, "%d", &si1Array[i]);
#endif
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 配列数
	siACnt = liCnt + 2;

	// 取りやめない時の合計値
	siSum = 0;
	for (i = 0; i < siACnt - 1; i++) {
		siSum += abs(si1Array[i] - si1Array[i + 1]);
	}

	// 取りやめる場合を出力
	for (i = 1; i < siACnt - 1; i++) {

		// 前後の金額減額
		int liSum = siSum;
		liSum -= abs(si1Array[i] - si1Array[i - 1]);
		liSum -= abs(si1Array[i] - si1Array[i + 1]);

		// ２マス移動額
		liSum += abs(si1Array[i - 1] - si1Array[i + 1]);

		// 結果セット
		sprintf(lc1Out, "%d\n", liSum);

		// 結果表示
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
		if (strcmp(lc1Buf, lc1Out)) {
			siRes = -1;
		}
#else
		printf("%s", lc1Out);
#endif
	}

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}
//  [javascript]
function Main(input) {
  input = input.split("\n");
  N = parseInt(input[0].split(" ")[0]);
  A = new Array(N+1);
  A[0]=0;
  tmp = input[1].split(" ");
  var sum=0;
  skip=new Array(N);
  noskip=new Array(N);
  for(i=1;i<=N;i++){
    A[i]=parseInt(tmp[i-1]);
    sum+=Math.abs(A[i]-A[i-1]);
    if(i!=N){
      skip[i-1]=Math.abs(parseInt(tmp[i])-A[i-1]);
      noskip[i-1]=Math.abs(A[i]-A[i-1])+Math.abs(parseInt(tmp[i])-A[i]);
    }else{
      skip[i-1]=Math.abs(0-A[i-1]);
      noskip[i-1]=Math.abs(A[i]-A[i-1])+Math.abs(0-A[i]);
    }
  }
  sum+=Math.abs(A[N]);
  ans=new Array(N);
  for(i=0;i<N;i++){
    ans[i]=sum-noskip[i]+skip[i];
  }
  var ans2=ans.join("\n");

  console.log('%s', ans2);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input){
	input=input.split(/\n|\s/);
	input.forEach(function(e,i,a){a[i]=Number(a[i]);});
	var ans="";
	var lg=input[0];
	input[0]=0;
	var kr=0;
	var aa=0;
	var ar=[];
	
	for(var i=1;i<=lg;i=(i+1)|0){
		aa=input[i]-input[i-1];
		kr+=(aa^(aa>>31))-(aa>>31);
		
		ar[i]=0;
		if((input[i]>input[i+1]&&input[i+1]>=input[i-1])||(input[i]<input[i+1]&&input[i+1]<=input[i-1])){
			ar[i]=input[i]-input[i+1];
			ar[i]=(ar[i]^(ar[i]>>31))-(ar[i]>>31);
			ar[i]=ar[i]<<1;
		}
		else if((input[i]>input[i-1]&&input[i-1]>=input[i+1])||(input[i]<input[i-1]&&input[i-1]<=input[i+1])){
			ar[i]=input[i]-input[i-1];
			ar[i]=(ar[i]^(ar[i]>>31))-(ar[i]>>31);
			ar[i]=ar[i]<<1;
		}
	}
	kr+=(input[lg]^(input[lg]>>31))-(input[lg]>>31);
	for(var i=1;i<=lg;i=(i+1)|0){
		aa=kr-ar[i];
		ans+=aa+"\n";
	}
	ans=ans.slice(0,ans.length-1);
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function main(s) {
  s = s.split('\n')[1].split(' ').map(n => Number(n));

  const points = [0, ...s, 0];
  const diff   = [];
  const answer = [];

  points.forEach((p, i, self) => {
    if (i < self.length - 1) diff.push(self[i + 1] - self[i]);
  });

  const sum = diff.map(n => Math.abs(n)).reduce((a, b) => a + b);

  for (let i = 1; i < points.length - 1; i++) {

    // 該当の地点(b)を飛ばした場合の移動距離(a to c)
    const skipped = Math.abs(points[i - 1] - points[i + 1]);

    // 飛ばす前の移動距離((a to b) + (b to c))
    const stepped = Math.abs(points[i - 1] - points[i]) + Math.abs(points[i] - points[i + 1]);

    // 変更される移動距離((a to c) - ((a to b) + (b to c)))
    const changed = skipped - stepped;

    answer.push(sum + changed);
  }

  console.log(answer.join('\n'));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var N = Number(line[0]);
	var tmp = line[1].split(" ");
	var A = [];

	var originalPrice = 0;

	var dist = function(a,b){
		return Math.abs(a-b);
	}

	for(var i = 0; i < N; i++){
		A[i] = Number(tmp[i]);
		if(i === 0){
			originalPrice += dist(0,A[0]);
		} else{
			originalPrice += dist(A[i-1],A[i]);
		}
	}
	originalPrice += dist(A[N-1],0);

	var ans = [];

	for(var j = 0; j < N; j++){
		if(j === 0){
			ans[j] = originalPrice - dist(0,A[0]) - dist(A[0],A[1]) + dist(0,A[1]);
		} else if(j === N-1){
			ans[j] = originalPrice - dist(A[N-2],A[N-1]) - dist(A[N-1],0) + dist(A[N-2],0);
		} else{
			ans[j] = originalPrice - dist(A[j-1],A[j]) - dist(A[j],A[j+1]) + dist(A[j-1],A[j+1]);
		}
	}

	console.log(ans.join("\n"));

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// C: Travelling Plan
"use strict";

const DEBUG_MODE = false;
const rawInput = DEBUG_MODE
  ? "2\n1 19"
  : require("fs")
      .readFileSync("/dev/stdin", "utf8")
      .trim();

const process = inputRaw => {
  const mainInputs = inputRaw.split("\n");
  const nodeCount = parseInt(mainInputs[0]);
  const paddedNodes = [
    0,
    ...mainInputs[1].split(" ").map(item => parseInt(item)),
    0,
  ];

  const totalDistance = paddedNodes.reduce(
    (acc, curr, index) =>
      index === 0 ? acc : acc + Math.abs(curr - paddedNodes[index - 1]),
    0
  );

  for (let i = 1; i < nodeCount + 1; i++) {
    const previousNode = paddedNodes[i - 1];
    const skippedNode = paddedNodes[i];
    const nextNode = paddedNodes[i + 1];

    const distanceToSubtract =
      Math.abs(skippedNode - previousNode) + Math.abs(skippedNode - nextNode);
    const distanceToAdd = Math.abs(previousNode - nextNode);

    console.log(totalDistance - distanceToSubtract + distanceToAdd);
  }
};

process(rawInput);
//  [javascript]
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt();
    let A = new Array(N + 2);
    for (let n = 1; n <= N; n++) A[n] = cin.getInt();
    A[0] = 0, A[N + 1] = 0;
    let D = 0;
    for (let n = 0; n <= N; n++) D += Math.abs(A[n] - A[n + 1]);
    for (let n = 1; n <= N; n++) {
        let ans = D - Math.abs(A[n - 1] - A[n]) - Math.abs(A[n] - A[n + 1]) + Math.abs(A[n - 1] - A[n + 1]);
        console.log(ans);
    }
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n+2)
	a[0], a[len(a)-1] = 0, 0
	for i := 1; i < len(a)-1; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	mv := 0
	for i := 1; i < len(a); i++ {
		mv += abs(a[i-1] - a[i])
	}

	wr := bufio.NewWriter(os.Stdout)
	for i := 1; i < len(a)-1; i++ {
		ans := mv - (abs(a[i-1]-a[i]) + abs(a[i+1]-a[i])) + abs(a[i+1]-a[i-1])
		wr.WriteString(strconv.Itoa(ans) + "\n")
	}
	wr.Flush()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n+2)
	a[0], a[len(a)-1] = 0, 0
	mv := 0
	for i := 1; i < len(a)-1; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		mv += abs(a[i-1] - a[i])
	}
	mv += abs(a[len(a)-2] - a[len(a)-1])

	wr := bufio.NewWriter(os.Stdout)
	for i := 1; i < len(a)-1; i++ {
		ans := mv - (abs(a[i-1]-a[i]) + abs(a[i+1]-a[i])) + abs(a[i+1]-a[i-1])
		wr.WriteString(strconv.Itoa(ans) + "\n")
	}
	wr.Flush()
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		var s int
		fmt.Scanf("%d", &s)
		as[i] = s
	}

	as = append([]int{0}, as...)
	as = append(as, 0)
	sum := 0
	ds := make([]int, len(as)-1)
	for i := 0; i < len(as)-1; i++ {
		d := as[i+1] - as[i]
		if d < 0 {
			d = -d
		}
		ds[i] = d
		sum += d
	}
	for i := 1; i < len(as)-1; i++ {
		d1 := as[i+1] - as[i-1]
		if d1 < 0 {
			d1 = -d1
		}
		d2 := as[i] - as[i-1]
		if d2 < 0 {
			d2 = -d2
		}
		d3 := as[i+1] - as[i]
		if d3 < 0 {
			d3 = -d3
		}
		fmt.Printf("%d\n", sum+d1-d2-d3)
	}
}
//  [go]
package main

import "fmt"

func abs(a, b int) int {
	if a < b {
		return b - a
	} else {
		return a - b
	}
}

type Table []int

func (t *Table) At(i int) int {
	i += t.Size()
	return (*t)[i%t.Size()]
}

func (t *Table) Size() int {
	return len(*t)
}

func (t *Table) Cost(i, j int) int {
	return abs(t.At(i), t.At(j))
}

func (t *Table) FullCost() int {
	cost := 0
	for i, _ := range *t {
		cost += t.Cost(i, i+1)
	}
	return cost
}

func (t *Table) ReductedCost(i int) int {
	return t.Cost(i-1, i) + t.Cost(i, i+1) - t.Cost(i-1, i+1)
}

func main() {
	var n int
	fmt.Scan(&n)
	var as Table = make([]int, n+1)

	as[0] = 0
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i+1])
	}

	full := as.FullCost()
	for i := 0; i < n; i++ {
		fmt.Println(full - as.ReductedCost(i+1))
	}
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n, n)
	totalA := 0
	prev := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		totalA = totalA + int(math.Abs(float64(prev-a[i])))
		prev = a[i]
	}
	totalA = totalA + int(math.Abs(float64(a[n-1])))

	answer := make([]int, n, n)
	prev1 := 0
	next1 := 0
	for i := 0; i < n; i++ {
		if i < (n - 1) {
			next1 = a[i+1]
		} else {
			next1 = 0
		}
		answer[i] = totalA - int(math.Abs(float64(prev1-a[i])))
		answer[i] = answer[i] - int(math.Abs(float64(a[i]-next1)))
		answer[i] = answer[i] + int(math.Abs(float64(prev1-next1)))

		prev1 = a[i]
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%d\n", answer[i])
	}
}
//  [ruby]
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

a = a.unshift(0).push(0)

s = 0
(n + 1).times{|i| s += (a[i + 1] - a[i]).abs}

n.times do |i|
  s_i = s + (a[i] - a[i + 2]).abs - (a[i] - a[i + 1]).abs - (a[i + 1] - a[i + 2]).abs
  puts s_i.to_s
end
//  [ruby]
n = gets.to_i
datas = gets.split(" ").map{|nn|nn.to_i}
datas << 0
datas.unshift(0)

base = 0
for i in 0..n
  base += (datas[i+1] - datas[i]).abs
end

for i in 1..n
  ans = base - (datas[i+1] - datas[i]).abs - (datas[i] - datas[i-1]).abs + (datas[i+1] - datas[i-1]).abs
  puts ans.to_s
end
//  [ruby]
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
a = a.unshift(0)
a << 0
ans = 0
i = 1
while true
    ans += (a[i] - a[i-1]).abs
    if i == n + 1
        break
    end
    i += 1
end
j = 1
while true
    all = ans
    kesumae = (a[j+1] -a[j-1]).abs
    #p kesumae
    keshitaato = (a[j]-a[j-1]).abs + (a[j+1]-a[j]).abs
    #p keshitaato
    ans += (kesumae - keshitaato)
    #p ans
    j += 1
    if j != n + 1
        puts ans
        ans = all
    else
        puts ans
        break
    end
end
//  [ruby]
N,*A_=`dd`.split.map &:to_i
A=0,*A_,0
S=A.each_cons(2).reduce(0){|s,(x,y)|s+(y-x).abs}
(1..N).map{|i|
	a=A[i]-A[i-1];b=A[i+1]-A[i]
	if a*b>0
		p S
	else
		p S-[a.abs,b.abs].min*2
	end
}
//  [ruby]
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gif
a = gi
cur = 0
sum = 0
rep n do |i|
  sum += (a[i] - cur).abs
  cur = a[i]
end

cur = 0
rep n do |i|
  tsum = sum
  tsum -= (a[i] - cur).abs
  tsum -= (a[i+1]-a[i]).abs if i < n-1
  tsum += (a[i+1] - cur).abs if i < n-1
  cur = a[i]
  add = i < n-1 ? a[-1] : a[-2]
  puts tsum + add.abs
end
//  [ruby]
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

a.unshift(0)
a.push(0)

k = 0
(n+1).times do |i|
  k += (a[i+1] - a[i]).abs
end

def same?(one, two, three)
  if two - one >= 0
    if three - two >= 0
      true
    else
      false
    end
  else
    if two - three >= 0
      true
    else
      false
    end
  end
end

n.times do |i|
  if same?(a[i], a[i+1], a[i+2])
    p k
  else
    if ((a[i+2] - a[i] >= 0) && (a[i] - a[i+1] >= 0)) || ((a[i+1] - a[i] >= 0) && (a[i] - a[i+2] >= 0))
      p k - (a[i+1] - a[i]).abs * 2
    else
      p k - (a[i+2] - a[i+1]).abs * 2
    end
  end
end
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        a: [i64;n],
    }

    let mut route = a[0].abs() + a[n-1].abs();
    for i in 1..n {
        route += (a[i] - a[i-1]).abs();
    }
    debug!(route);

    println!("{}", route-a[0].abs()-(a[1]-a[0]).abs()+a[1].abs());
    for i in 1..n-1 {
        let route_tmp = route - (a[i]-a[i-1]).abs() -(a[i+1]-a[i]).abs()+ (a[i+1]-a[i-1]).abs();
        println!("{}", route_tmp);
        debug!(route_tmp);
    }
    println!("{}", route-a[n-1].abs()-(a[n-1]-a[n-2]).abs()+a[n-2].abs());
}
//  [rust]
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }

    let b = {
        let mut sum = 0;
        for i in 0..n - 1 {
            sum += (a[i + 1] - a[i]).abs()
        }
        sum += a[0].abs();
        sum += a[n - 1].abs();
        sum
    };

    let mut c = vec![0; n];
    for (i, x) in a.iter().enumerate() {
        let l = if i == 0 { 0 } else { a[i - 1] };
        let r = if i == n - 1 { 0 } else { a[i + 1] };

        let y = (x - l).abs() + (r - x).abs();
        let z = (r - l).abs();
        c[i] = z - y;
    }

    // for x in &c {
    //     print!("{}, ", x);
    // }
    // println!();

    for (i, x) in a.iter().enumerate() {
        println!("{}", b + c[i]);
    }
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = vec![];

    for _ in 0..n {
        let ai = read();
        a.push(ai);
    }
    let mut sum = 0;
    let mut head = 0;

    for i in 0..n {
        let ai = a[i];
        sum += (head - ai).abs();
        head = ai;
    }
    sum += head.abs();

    // println!("sum:{}", sum);

    let mut prev = 0;
    for i in 0..n {
        let current = a[i];
        let mut next = 0;
        if i != n - 1 {
            next = a[i + 1];
        }
        println!(
            "{}",
            sum - (prev - current).abs() - (current - next).abs() + (prev - next).abs()
        );
        prev = current;
    }
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var aryA = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    aryA.insert(0, at: 0)
    aryA.append(0)
    
    var ans = 0
    for i in 1..<aryA.count {
        ans += abs(aryA[i] - aryA[i - 1])
    }
    
    for i in 2..<aryA.count {
        print(ans + abs(aryA[i - 2] - aryA[i]) - abs(aryA[i - 2] - aryA[i - 1]) - abs(aryA[i - 1] - aryA[i]))
    }
}
main()
//  [typescript]
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];
const a = input[1].split(" ").map((x: string): number => +x);
a.unshift(0);
a.push(0);

const dist = (a: number, b: number) => {
	return Math.abs(a - b);
};

let sum = 0;
for (let i = 0; i < a.length - 1; i++) {
	sum += dist(a[i], a[i + 1]);
}

for (let i = 1; i <= n; i++) {
	const prev = a[i - 1];
	const mid = a[i];
	const next = a[i + 1];
	const original_cost = dist(next, mid) + dist(mid, prev);
	const new_cost = dist(next, prev);
	console.log(sum - (original_cost - new_cost));
}