#include <bits/stdc++.h>
#include <math.h>
//in the name of god,aka allah
//**sarv chaman man chera meyl chaman nemikonad**
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define pi pair<long long , long long>
#define pii pair<long long , pair<long long , long long>>
const int maxm = 5e5 + 3;
const long long mod =1e9 + 7;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
ll l,r,mid;
ll n,m;
ll dis[maxm] , sum[maxm];
bool isval(int mid){
//cout << mid <<" " << mid*mid-mid <<endl;
if (((mid-1)*mid)/2 < m) return 0;
return 1;
}
ll darage[maxm] , ss , mm;
queue<int> q;
vector<pi> g[maxm] , z[maxm];
ll sath[maxm];
bool vis[maxm] , gos[maxm];
ll pedaret[maxm];
ll get_par(ll v){
if (pedaret[v]==v) return v;
return pedaret[v] = get_par(pedaret[v]);
}
void merge(ll r , ll q){
if (get_par(r)!=get_par(q))l+=max(darage[r],darage[q])*1ll*sath[r]*1ll*sath[q];
r = get_par(r) , q = get_par(q);
if (r!=q){
if (sath[r]<sath[q]) swap(r,q);
pedaret[q] = r;
sath[r] += sath[q];
}
return ;
}
ll pars1[maxm] , pars2[maxm];
vector<ll> se[maxm];
multiset<int> st;
ll rp[maxm];
pi w[maxm];
ll dp[maxm * 2];
//ll rw[maxm][maxm];
map<ll,ll> mp;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >>n;
set<pi> st;
for (int i=1; i<=n; i++){
cin>>pedaret[i];
st.insert({pedaret[i],i});
}
for (int i=n; i; i--){
if (!vis[i]){
darage[i] = -1;
while (st.size() && (*st.rbegin()).fi>pedaret[i]){
vis[(*st.rbegin()).se] = 1;
darage[(*st.rbegin()).se] = i-(*st.rbegin()).se-1;
st.erase(*st.rbegin());
}
st.erase({pedaret[i],i});
}
}
for (int i=1; i<=n; i++) cout<<darage[i]<<" ";
}
1486B - Eastern Exhibition | 1363A - Odd Selection |
131B - Opposites Attract | 490C - Hacking Cypher |
158B - Taxi | 41C - Email address |
1373D - Maximum Sum on Even Positions | 1574C - Slay the Dragon |
621A - Wet Shark and Odd and Even | 1395A - Boboniu Likes to Color Balls |
1637C - Andrew and Stones | 1334B - Middle Class |
260C - Balls and Boxes | 1554A - Cherry |
11B - Jumping Jack | 716A - Crazy Computer |
644A - Parliament of Berland | 1657C - Bracket Sequence Deletion |
1657B - XY Sequence | 1009A - Game Shopping |
1657A - Integer Moves | 230B - T-primes |
630A - Again Twenty Five | 1234D - Distinct Characters Queries |
1183A - Nearest Interesting Number | 1009E - Intercity Travelling |
1637B - MEX and Array | 224A - Parallelepiped |
964A - Splits | 1615A - Closing The Gap |