#include <bits/stdc++.h>
#define BPhuong "main"
#define maxn 200005
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define ll long long
#define bit(i, j) ((i >> j) & 1)
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back

using namespace std;
int n;
pii e[maxn];
int it[4 * maxn][2], p[maxn], st[4 * maxn], l[maxn];
void build(int id, int l, int r){
    if(l == r){
        it[id][0] = it[id][1] = p[l];
        st[id] = 0;
        return;
    }
    int mid = (l + r) / 2;
    build(id * 2, l, mid);
    build(id * 2 + 1, mid + 1, r);
    st[id] = 0;
    it[id][0] = min(it[id * 2][0], it[id * 2 + 1][0]);
    it[id][1] = max(it[id * 2][1], it[id * 2 + 1][1]);
}
void lazy(int id){
    it[id * 2][0] += st[id];
    it[id * 2 + 1][0] += st[id];
    it[id * 2][1] += st[id];
    it[id * 2 + 1][1] += st[id];
    st[id * 2] += st[id];
    st[id * 2 + 1] += st[id];
    st[id] = 0;
    return;
}
void upp(int id, int l, int r, int u, int v, int val){
    if(l > v || r < u) return;
    if(u <= l && r <= v){
        it[id][0] += val;
        it[id][1] += val;
        st[id] += val;
        return;
    }
    lazy(id);
    int mid = (l + r) / 2;
    upp(id * 2, l, mid, u, v, val);
    upp(id * 2 + 1, mid + 1, r, u, v, val);
    it[id][0] = min(it[id * 2][0], it[id * 2 + 1][0]);
    it[id][1] = max(it[id * 2][1], it[id * 2 + 1][1]);
}
int get(int id, int l, int r, int u, int v){
    if(l > v || r < u) return maxn;
    if(u <= l && r <= v) return it[id][0];
    lazy(id);
    int mid = (l + r) / 2;
    return min(get(id * 2, l, mid, u, v), get(id * 2 + 1, mid + 1, r, u, v));
}
int get2(int id, int l, int r, int u, int v){
    if(l > v || r < u) return -maxn;
    if(u <= l && r <= v) return it[id][1];
    lazy(id);
    int mid = (l + r) / 2;
    return max(get2(id * 2, l, mid, u, v), get2(id * 2 + 1, mid + 1, r, u, v));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    #ifndef ONLINE_JUDGE
    freopen(BPhuong ".inp", "r", stdin);
    freopen(BPhuong ".out", "w", stdout);
    #endif // ONLINE_JUDGE
    cin >> n;
    ll tg = 0;
    fi(i, 1, n){
        int a;
        cin >> a;
        if(a > 42) tg -= 1; else tg += 1;
        e[i] = {a, i};
        p[i] = p[i - 1] + 1;
    }
    build(1, 0, n);
    sort(e + 1, e + n + 1);
    int j = 1;
    while(j <= n){
        int d = j, c = n;
        while(d <= c){
            int g = (d + c) / 2;
            if(e[g].f > e[j].f) c = g - 1;
            else d = g + 1;
        }
        fi(i, j, c){
            upp(1, 0, n, e[i].se, n, -1);
            int mi = get(1, 0, n, 0, e[i].se - 1);
            int ma = get2(1, 0, n, e[i].se, n);
            if(ma >= mi) l[e[i].se] = max(0, (ma - mi + 1) / 2);
            upp(1, 0, n, e[i].se, n, 1);
        }
        fi(i, j, c) upp(1, 0, n, e[i].se, n, -2);
        j = d;
    }
    build(1, 0, n);
    j = n;
    while(j >= 1){
        int d = 1, c = j;
        while(d <= c){
            int g = (d + c) / 2;
            if(e[g].f < e[j].f) d = g + 1;
            else c = g - 1;
        }
        fi(i, d, j){
            upp(1, 0, n, e[i].se, n, -1);
            int mi = get(1, 0, n, 0, e[i].se - 1);
            int ma = get2(1, 0, n, e[i].se, n);
            if(ma >= mi) l[e[i].se] = max(l[e[i].se], (ma - mi) / 2);
            upp(1, 0, n, e[i].se, n, 1);
        }
        fi(i, d, j) upp(1, 0, n, e[i].se, n, -2);
        j = c;
    }
    fi(i, 1, n) cout << l[i] << ' ';
}
