#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n;
stack<int> s;
LL arr[maxn];
int left[maxn],right[maxn];
LL sum[maxn];
void solve1(){
while(!s.empty()) s.pop();
for(int i=1;i<=n;i++){
LL e = arr[i];
do{
if(s.empty()){
left[i]=0;
s.push();
break;
}
LL c = arr[s.top()];
if(c < e){
left[i]=s.top();
s.push(i);
break;
}
else s.pop();
}while(true);
}
}
void solve2(){
while(!s.empty()) s.pop();
for(int i=n;i>=1;i--){
LL e = arr[i];
do{
if(s.empty()){
right[i]=n+1;
s.push(i);
break;
}
LL c=arr[s.top()];
if(c<e){
right[i]=s.top();
s.push(i);
break;
}
else s.pop();
}while(true);
}
}
int main()
{
int Case=0;
while(scanf("%d",&n)!=EOF){
sum[0]=0L;
for(int i=1;i<=n;i++)
{
scanf("%lld",&arr[i]);
sum[i]=sum[i-1]+arr[i];
}
solve1();
solve2();
LL ans=-1;
int pos_x,pos_y;
int l;
for(int i=1;i<=n;i++){
int a=left[i];
int b=right[i];
int ll
}
}
return 0;
}
using namespace std;
const int maxn = 100005;
int n;
stack<int> s;
LL arr[maxn];
int left[maxn],right[maxn];
LL sum[maxn];
void solve1(){
while(!s.empty()) s.pop();
for(int i=1;i<=n;i++){
LL e = arr[i];
do{
if(s.empty()){
left[i]=0;
s.push();
break;
}
LL c = arr[s.top()];
if(c < e){
left[i]=s.top();
s.push(i);
break;
}
else s.pop();
}while(true);
}
}
void solve2(){
while(!s.empty()) s.pop();
for(int i=n;i>=1;i--){
LL e = arr[i];
do{
if(s.empty()){
right[i]=n+1;
s.push(i);
break;
}
LL c=arr[s.top()];
if(c<e){
right[i]=s.top();
s.push(i);
break;
}
else s.pop();
}while(true);
}
}
int main()
{
int Case=0;
while(scanf("%d",&n)!=EOF){
sum[0]=0L;
for(int i=1;i<=n;i++)
{
scanf("%lld",&arr[i]);
sum[i]=sum[i-1]+arr[i];
}
solve1();
solve2();
LL ans=-1;
int pos_x,pos_y;
int l;
for(int i=1;i<=n;i++){
int a=left[i];
int b=right[i];
int ll
}
}
return 0;
}