intread(){ int x = 0; char c = gc(); while (!isdigit(c)) c = gc(); while (isdigit(c)) x = x * 10 + c - '0', c = gc(); return x; }
int n;
structnode { int p, v; } st[maxn]; int top;
int ans[maxn]; intmain(){ n = read(); for (int i = 1; i <= n; ++i) { int v = read(); while (top && st[top].v < v) ans[st[top].p] = i, --top; st[++top].v = v; st[top].p = i; } for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]); return0; }