// trust yourself ba2a ysta
// hategy kda kda
// lw m4 elnhrda , bokra ^_^
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(st) int(st.size())
#define all(st) st.begin(), st.end()
const int MAX_N = 1e5 + 10;
int seg[(MAX_N * 4)]; // fill with -1
int tree_size = 1;
void update(int idx, int val)
{
idx += tree_size;
seg[idx] = max(seg[idx], val);
for (idx /= 2;idx >= 1;idx /= 2)
seg[idx] = max(seg[idx * 2], seg[idx * 2 + 1]);
}
int query(int L, int R)
{
L += tree_size, R += tree_size;
int ret = -1;
while (L <= R)
{
if (L & 1) ret = max(ret, seg[L++]);
if (!(R & 1)) ret = max(ret, seg[R--]);
L /= 2, R /= 2;
}
return ret;
}
void Solve()
{
int n; cin >> n;
vector < int > a(n + 1);
for (int i = 1;i <= n;i++)
cin >> a[i];
vector < int > temp = a;
sort(all(temp));
temp.erase(unique(all(temp)), temp.end());
for (int i = 1;i <= n;i++)
{
a[i] = upper_bound(all(temp), a[i]) - temp.begin();
}
while (tree_size < sz(a))
tree_size *= 2;
deque < int > ans;
for (int i = n; i >= 1; i--)
{
int cur_val = a[i];
int less_idx = query(1, cur_val - 1);
if (~less_idx) ans.push_front(abs(less_idx - i - 1));
else ans.push_front(-1);
update(cur_val, i);
}
for (auto i : ans)
{
cout << i << " ";
}
}
signed main()
{
#if LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
//cin >> t;
fill(seg, seg + (MAX_N * 4), -1);
for (int tc = 1; tc <= t; tc++) {
Solve();
cout << "\n";
}
return 0;
}
Ly8gdHJ1c3QgeW91cnNlbGYgYmEyYSB5c3RhCi8vIGhhdGVneSBrZGEga2RhCi8vIGx3IG00IGVsbmhyZGEgLCBib2tyYSBeX14KI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIGxsID0gbG9uZyBsb25nOwoj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ogICAgewogICAgICAgIGFbaV0gPSB1cHBlcl9ib3VuZChhbGwodGVtcCksIGFbaV0pIC0gdGVtcC5iZWdpbigpOwogICAgfQoKICAgIHdoaWxlICh0cmVlX3NpemUgPCBzeihhKSkKICAgICAgICB0cmVlX3NpemUgKj0gMjsKCgoKICAgIGRlcXVlIDwgaW50ID4gYW5zOwoKICAgIGZvciAoaW50IGkgPSBuOyBpID49IDE7IGktLSkKICAgIHsKICAgICAgICBpbnQgY3VyX3ZhbCA9IGFbaV07CgogICAgICAgIGludCBsZXNzX2lkeCA9IHF1ZXJ5KDEsIGN1cl92YWwgLSAxKTsKCiAgICAgICAgaWYgKH5sZXNzX2lkeCkgYW5zLnB1c2hfZnJvbnQoYWJzKGxlc3NfaWR4IC0gaSAtIDEpKTsKICAgICAgICBlbHNlIGFucy5wdXNoX2Zyb250KC0xKTsKCiAgICAgICAgdXBkYXRlKGN1cl92YWwsIGkpOwogICAgfQoKCiAgICBmb3IgKGF1dG8gaSA6IGFucykKICAgIHsKICAgICAgICBjb3V0IDw8IGkgPDwgIiAiOwogICAgfQoKfQoKc2lnbmVkIG1haW4oKQp7CiNpZiBMT0NBTAogICAgZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgICBmcmVvcGVuKCJvdXRwdXQudHh0IiwgInciLCBzdGRvdXQpOwojZW5kaWYKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZShudWxscHRyKTsKICAgIGludCB0ID0gMTsKICAgIC8vY2luID4+IHQ7CiAgICBmaWxsKHNlZywgc2VnICsgKE1BWF9OICogNCksIC0xKTsKICAgIGZvciAoaW50IHRjID0gMTsgdGMgPD0gdDsgdGMrKykgewogICAgICAgIFNvbHZlKCk7CiAgICAgICAgY291dCA8PCAiXG4iOwogICAgfQogICAgcmV0dXJuIDA7Cn0K