#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define inf  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<ll,ll>
            #define ppa pair<int,pa>
            #define  mp make_pair
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
            //----------------kokomade temple------------
int n,x,k;
string s[10];
    signed main(){
cin>>n;
    	int p[20004];
    	for(int i=1;i<=n;i++){
cin>>p[i];
    	}
    	
    	
    	int a[20004],b[20004];
    	a[p[1]]=0,b[p[1]]=0;
    	for(int i=1;i<=n-1;i++){
    		if(p[i]>p[i+1]){
    			a[p[i+1]]= a[p[i]]-1;
    			b[p[i+1]]= b[p[i]]+2;
    			
    		}
    		else{
    			a[p[i+1]]= a[p[i]]+2;
    			b[p[i+1]]= b[p[i]]-1;
    		}
    		
    		
    	}
    	for(int i=1;i<=n-1;i++){
//cout<<a[i]<<" "<<b[i]<<endl;
    		
    		int d=max(a[i]-a[i+1],b[i+1]-b[i]);
    		if(d<0) continue;
    		
    		a[i+1] += (d+1);
    		b[i+1] -= (d+1);
    	}
    	int am=0,bm=0;
    	  	for(int i=1;i<=n;i++){
    	  		am=min(am,a[i]);
    	  		bm=min(bm,b[i]);
    	}
    		for(int i=1;i<=n;i++){
    			if(am<=0)		a[i] += (1-am);
    			if(bm<=0)		b[i] += (1-bm);
    	}
    	
    	   	for(int i=1;i<=n;i++){
    	   		if(i==1) cout<<a[i];
    		    	else cout<<" "<<a[i];
    	}
    	cout<<endl;
    	   	for(int i=1;i<=n;i++){
    	   		if(i==1) cout<<b[i];
    		    	else cout<<" "<<b[i];
    	}
    	cout<<endl;
    	
    			return 0;
    	
    //	printf("%.10f\n",ans);
    	return 0;
    }

Measured memory_bytes: 1024