#include<bits/stdc++.h> usingnamespacestd; constint N = 250000 + 10; int n, a[N], c[N], ans[N]; voidupd(int x, int y){ while (x < N) c[x] = max(c[x], y), x += x & -x; } intqry(int x){ int s = 0; while (x) s = max(s, c[x]), x -= x & -x; return s; } vector<int> v[N]; int f[N][18], d[N]; intfind(int x, int y){ int l = 0, r = v[x].size() - 1; while (l < r) { int mid = (l + r) >> 1; if (a[v[x][mid]] > y) l = mid + 1; else r = mid; } return l; } intlca(int x, int y){ if (d[x] < d[y]) swap(x, y); for (int i = 17; ~i; --i) if (d[f[x][i]] >= d[y]) x = f[x][i]; if (x ^ y) { for (int i = 17; ~i; --i) if (f[x][i] ^ f[y][i]) x = f[x][i], y = f[y][i]; x = f[x][0], y = f[y][0]; } return x; } voidLIS(){ for (int i = 1; i <= n; i++) { int prv = qry(a[i]); v[prv + 1].push_back(i); upd(a[i], prv + 1); int pos = find(prv, a[i]); int fx = lca(v[prv][pos], v[prv].back()); f[i][0] = fx; d[i] = d[fx] + 1; for (int j = 1; j < 18; j++) f[i][j] = f[f[i][j - 1]][j - 1]; } } intmain(){ scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); v[0].push_back(0); LIS(); for (int i = 1; i <= n; ++i) ans[i] += d[i] - 1; memset(f, 0, sizeof(f)); memset(c, 0, sizeof(c)); memset(d, 0, sizeof(d)); reverse(a + 1, a + n + 1); for (int i = 1; i <= n; ++i) a[i] = n + 1 - a[i]; for (int i = 1; i <= n; ++i) v[i].clear(); LIS(); for (int i = 1; i <= n; ++i) printf("%d%c", ans[i] + d[n + 1 - i] - 1, " \n"[i == n]); return0; }