//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int n, x[200005], y[200005], p[200005], rev[200005];
ll ans[200005];
vector<int>zax, zay;
//0...-1 1...+1
int L[2][200005], R[2][200005];
map<P, pair<ll, ll>>cache;
ll get_dist(int a, int b){
	return abs(zax[a]-zax[b]) + abs(zay[p[a]]-zay[p[b]]);
}
int Mi;
//first...(lb, p[lb]) second...(ub,p[ub])
pair<ll, ll>solve(int lb, int ub, int mn, int mx){
	if(cache.find(mp(lb, ub)) != cache.end()) return cache[mp(lb, ub)];
	if( (lb > 0 && p[lb-1] == mn-1) || (ub < n-1 && p[ub+1] == mx+1) ){
		// bottom left - upper right
		int Lz = (lb > 0 && p[lb-1] == mn-1) ? L[0][lb-1] : lb;
		int Rz = (ub < n-1 && p[ub+1] == mx+1) ? R[1][ub+1] : ub;
		auto ret = solve(Lz, Rz, min(mn, p[Lz]), max(mx, p[Rz]));
		ll all = get_dist(Lz, Rz);
		ll F = min(ub!=Rz?get_dist(lb,Rz)+all+ret.fi:get_dist(lb, Lz)+ret.fi, lb!=Lz?get_dist(lb,Lz)+all+ret.sc:get_dist(lb, Rz)+ret.sc);
		ll S = min(lb!=Lz?get_dist(ub,Lz)+all+ret.sc:get_dist(ub, Rz)+ret.sc, ub!=Rz?get_dist(ub,Rz)+all+ret.fi:get_dist(ub, Lz)+ret.fi);
		return cache[mp(lb, ub)] = mp(F, S);
	}
	else if( (lb > 0 && p[lb-1] == mx+1) || (ub < n-1 && p[ub+1] == mn-1)){
		// upper left - bottom right
		int Lz = (lb > 0 && p[lb-1] == mx+1) ? L[1][lb-1] : lb;
		int Rz = (ub < n-1 && p[ub+1] == mn-1) ? R[0][ub+1] : ub;
		auto ret = solve(Lz, Rz, min(mn, p[Rz]), max(mx, p[Lz]));
		ll all = get_dist(Lz, Rz);
		ll F = min(ub!=Rz?get_dist(lb,Rz)+all+ret.fi:get_dist(lb, Lz)+ret.fi, lb!=Lz?get_dist(lb,Lz)+all+ret.sc:get_dist(lb, Rz)+ret.sc);
		ll S = min(lb!=Lz?get_dist(ub,Lz)+all+ret.sc:get_dist(ub, Rz)+ret.sc, ub!=Rz?get_dist(ub,Rz)+all+ret.fi:get_dist(ub, Lz)+ret.fi);
		return cache[mp(lb, ub)] = mp(F, S);
	}
	else{
		//end
		Mi = ub-lb;
		return mp(0ll, 0ll);
	}
}
int main(){
	scanf("%d", &n);
	rep(i, n){
		scanf("%d%d", &x[i], &y[i]);
		zax.pb(x[i]); zay.pb(y[i]);
	}
	SORT(zax); SORT(zay);
	rep(i, n){
		x[i] = POSL(zax, x[i]);
		y[i] = POSL(zay, y[i]);
		p[x[i]] = y[i];
		rev[x[i]] = i;
	}
	rep(i, n){
		if(i == 0 || p[i]-1 != p[i-1]) L[0][i] = i;
		else L[0][i] = L[0][i-1];
		
		if(i == 0 || p[i]+1 != p[i-1]) L[1][i] = i;
		else L[1][i] = L[1][i-1];
	}
	for(int i=n-1;i>=0;i--){
		if(i == n-1 || p[i]-1 != p[i+1]) R[0][i] = i;
		else R[0][i] = R[0][i+1];
		
		if(i == n-1 || p[i]+1 != p[i+1]) R[1][i] = i;
		else R[1][i] = R[1][i+1];
	}
	rep(i, n){
		auto ret = solve(i, i, p[i], p[i]);
		assert(ret.fi == ret.sc);
		ans[rev[i]] = ret.fi - Mi;
	}
	rep(i, n) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 51892