#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  vector<int> a(n, 0);
  vector<ll> ans(n, 0);
  ll fee = 0;
  for (ll i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  ll tmp = 0;
  for (ll i = 0; i < n + 1; i++)
  {
    if (i == n)
    {
      fee += abs(tmp - 0);
      break;
    }

    fee += abs(tmp - a[i]);
    tmp = a[i];
  }

  for (ll i = 0; i < n; i++)
  {
    ans[i] = fee - (abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i])) + (abs(a[i + 1] - a[i - 1]));
  }

  for (ll i = 0; i < n; i++)
  {
    cout << ans[i] << endl;
  }
}

#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;



int main(void){

string ws;
int n;
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		vector<vector<int> > hg(n+1,vector<int>(n+1,0));
		rep(i,n) rep(j,n) cin >> hg[i][j];
		rep(i,n) rep(j,n){
			hg[n][i] += hg[j][i];
			hg[i][n] += hg[i][j];
		}
		rep(i,n) hg[n][n] += hg[i][n];
		rep(i,n+1){
			rep(j,n+1) printf("%5d",hg[i][j]);
			printf("\n");
		}
	}
	return 0;
	
}