#include <stdio.h>
#include <memory.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int N = 200005;

struct Z {
    int v, id;
    bool operator < (const struct Z &o) const {
        return v < o.v;
    }
} z[N];

int ans[N] = { 0 }, la[N*4] = { 0 }, ax[N*4] = { 0 }, in[N*4] = { 0 };

void build(int id, int p, int q) {
    if (p == q) {
        la[id] = 0;
        ax[id] = in[id] = p;
        return;
    }
    int mid = (p + q) / 2, left = id + id, right = left + 1;
    build(left, p, mid);
    build(right, mid + 1, q);
    la[id] = 0;
    ax[id] = max(ax[left], ax[right]);
    in[id] = min(in[left], in[right]);
}
void push(int id, int left, int right) {
    ax[left] += la[id];
    in[left] += la[id];
    la[left] += la[id];
    ax[right] += la[id];
    in[right] += la[id];
    la[right] += la[id];
    la[id] = 0;
}
void up(int id, int p, int q, int pp, int qq) {
    if (p == pp && q == qq) {
        ax[id] -= 2;
        in[id] -= 2;
        la[id] -= 2;
        return;
    }
    int mid = (p + q) / 2, left = id + id, right = left + 1;
    if (la[id]) push(id, left, right);
    if (pp > mid) up(right, mid + 1, q, pp, qq);
    else if (qq <= mid) up(left, p, mid, pp, qq);
    else {
        up(left, p, mid, pp, mid);
        up(right, mid + 1, q, mid + 1, qq);
    }
    ax[id] = max(ax[left], ax[right]);
    in[id] = min(in[left], in[right]);
}
int find_max(int id, int p, int q, int pp, int qq) {
    if (p == pp && q == qq) {
        return ax[id];
    }
    int mid = (p + q) / 2, left = id + id, right = left + 1;
    if (la[id]) push(id, left, right);
    if (pp > mid) return find_max(right, mid + 1, q, pp, qq);
    else if (qq <= mid) return find_max(left, p, mid, pp, qq);
    else {
        return max(
        find_max(left, p, mid, pp, mid),
        find_max(right, mid + 1, q, mid + 1, qq));
    }
}
int find_min(int id, int p, int q, int pp, int qq) {
    if (p == pp && q == qq) {
        return in[id];
    }
    int mid = (p + q) / 2, left = id + id, right = left + 1;
    if (la[id]) push(id, left, right);
    if (pp > mid) return find_min(right, mid + 1, q, pp, qq);
    else if (qq <= mid) return find_min(left, p, mid, pp, qq);
    else {
        return min(
        find_min(left, p, mid, pp, mid),
        find_min(right, mid + 1, q, mid + 1, qq));
    }
}


void solve() {
    int now = 0, n = 0, i = 0, k = 0, ax = 0, in = 0;
    scanf("%d", &n);
    for (i = 1; i <= n; i ++) {
        scanf("%d", &z[i].v);
        z[i].id = i;
    }
    sort(z + 1, z + 1 + n);

    build(1, 0, n);
    k = 1;
    for (i = 1; i <= n; i ++) {
        while (k <= n && z[k].v < z[i].v) {
            up(1, 0, n, z[k].id, n);
            k ++;
        }
        ax = find_max(1, 0, n, z[i].id, n);
        in = find_min(1, 0, n, 0, z[i].id - 1);
        ans[z[i].id] = (ax - in) / 2;
    }

    build(1, 0, n);
    k = 1;
    for (i = 1; i <= n; i ++) {
        while (k <= n && z[k].v <= z[i].v) {
            up(1, 0, n, z[k].id, n);
            k ++;
        }
        in = find_min(1, 0, n, z[i].id, n);
        ax = find_max(1, 0, n, 0, z[i].id - 1);
        now = (ax - in - 1) / 2;
        if (now > ans[z[i].id]) ans[z[i].id] = now;
    }
    for (i = 1; i <= n; i ++) {
        printf("%d", ans[i]);
        if (i < n) printf(" ");
        else printf("\n");
    }
}

int main() {
    int o = 1;
    //scanf("%d", &o);
    while (o --) {
        solve();
        //fflush(stdout);
    }
    return 0;
}

