#include<stdio.h>
int a[100001]= {};
int b[100001] = {0};
int bs(int s, int e, int k)
{
int mid=(s+e)/2;
if(s>e) return -1;
if(a[mid]==k) return mid;
else if(a[mid]<k) bs(mid+1,e,k);
else bs(s,mid-1,k);
}
void quick_sort(int s, int e)
{
int temp;
int pivot=s;
int low=s,high=e;
if(s>=e)
return ;
while(low<high)
{
while(a[pivot]>a[low])
low++;
while(a[pivot]<a[high])
high--;
if(low<high)
{
temp = a[low];
a[low] = a[high];
a[high] = temp;
}
}
temp = a[pivot];
a[pivot] = a[high];
a[high] = temp;
quick_sort(s,high-1);
quick_sort(high+1,e);
}
int main()
{
int i, n;
scanf("%d", &n);
for(i=1;i<=n;i++)
{
scanf("%d", &a[i]);
b[i] = a[i];
}
quick_sort(1,n);
//
for(i=1;i<=n;i++){
}
for(i=1; i<=n; i++) {
printf("%d ", b[i]);
}
printf("\n");
for(i=1;i<=n;i++)
{
printf("%d ",bs(s, e, k));
}
}
printf("%d ",bs(s, e, k));
}
}