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

vector<int> get_bigger_left(const vector<int> &H) {
    int N = H.size();
    vector<int> answer(N,-1), idx(1,-1), hei(1,1000000007);
    for (int n=0; n<N; ++n) {
        while (hei.back() <= H[n]) { hei.pop_back(); idx.pop_back(); }
        answer[n] = idx.back();
        hei.push_back(H[n]); idx.push_back(n);
    }
    return answer;
}

vector<int> get_bigger_right(const vector<int> &H) {
    vector<int> Hcopy = H;
    reverse( Hcopy.begin(), Hcopy.end() );
    vector<int> answer = get_bigger_left(Hcopy);
    reverse( answer.begin(), answer.end() );
    for (int &x : answer) x = H.size() - 1 - x;
    return answer;
}

struct intervalac {
    int N, L;
    vector< vector<int> > T;
    
    int min_query(int lo, int hi, int r=-1, int c=-1, int tlo=-1, int thi=-1) {
        if (r == -1) { r=0; c=0; tlo=0; thi=1<<L; }
        if (thi <= lo || hi <= tlo) return 1000000007;
        if (lo <= tlo && thi <= hi) return T[r][c];
        return min( 
            min_query( lo, hi, r+1, 2*c,   tlo, (tlo+thi)/2 ), 
            min_query( lo, hi, r+1, 2*c+1, (tlo+thi)/2, thi )
        );
    }

    intervalac(const vector<int> &H) {
        N = H.size();
        L = 0;
        while ((1 << L) < N) ++L;
        T.resize(L+1);
        for (int l=0; l<=L; ++l) T[l].resize(1<<l, 1000000007);
        for (int n=0; n<N; ++n) T[L][n] = H[n];
        for (int l=L-1; l>=0; --l) for (int i=0; i<(1<<l); ++i)
            T[l][i] = min( T[l+1][2*i], T[l+1][2*i+1] );
    }
};

int main() {
    // nacitame vstup a odstranime po sebe iduce duplikaty
    int N;
    cin >> N;
    vector<int> pohorie;
    for (int n=0; n<N; ++n) {
        int vyska;
        cin >> vyska;
        if (n == 0 || vyska != pohorie.back()) pohorie.push_back(vyska);
    }
    N = pohorie.size();
    int everest = *max_element( pohorie.begin(), pohorie.end() );

    // najdeme pre kazdy bod najblizsi vacsi vlavo aj vpravo, predpocitame minima
    vector<int> BL = get_bigger_left(pohorie), BR = get_bigger_right(pohorie);
    intervalac T(pohorie);

    // pre kazdy vrchol najdeme a vypiseme jeho prominenciu
    for (int kto=0; kto<N; ++kto) {
        if (kto-1 >= 0 && pohorie[kto-1] >= pohorie[kto]) continue;
        if (kto+1 <  N && pohorie[kto+1] >= pohorie[kto]) continue;
        if (pohorie[kto] == everest) { cout << everest << "\n"; continue; }
        int left = 1000000007, right = 1000000007;
        if (BL[kto] != -1) left = pohorie[kto] - T.min_query(BL[kto]+1,kto);
        if (BR[kto] != N) right = pohorie[kto] - T.min_query(kto+1,BR[kto]);
        cout << min(left,right) << "\n";
    }
}
