//lg p1368
//Copyright yeyou26
#include<bits/stdc++.h>
using namespace std;
const int N = 300005;
int a[2*N];
int n;
void init()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
long long x;
scanf("%d",&x);
a[i]=a[i+n]=x;
}
}
void solve()
{
int i=1,j=2,k=0;
while(i<=n && j<=n)
{
k=0;
while(a[i+k]==a[j+k] && k<n) k++;
if(a[i+k]>a[j+k]) i=i+k+1;
else j=j+k+1;
if(k==n) break;
if(i==j) j++;
}
int ans=min(i,j);
for(int p=1;p<=n;p++)
{
printf("%d ",a[ans+p-1]);
}
}
int main()
{
freopen("working.in","r",stdin);
freopen("working.out","w",stdout);
init();
solve();
return 0;
}