Problem:
Score : 400 points

Problem Statement

#nck {
width: 30px;
height: auto;
}

You are given a permutation p of the set {1, 2, ..., N}. Please construct two sequences of positive integers a_1, a_2, ..., a_N and b_1, b_2, ..., b_N satisfying the following conditions:

1 \leq a_i, b_i \leq 10^9 for all i

a_1 < a_2 < ... < a_N

b_1 > b_2 > ... > b_N

a_{p_1}+b_{p_1} < a_{p_2}+b_{p_2} < ... < a_{p_N}+b_{p_N}

Constraints

2 \leq N \leq 20,000

p is a permutation of the set {1, 2, ..., N}

Input

The input is given from Standard Input in the following format:

N
p_1 p_2 ... p_N

Output

The output consists of two lines. The first line contains a_1, a_2, ..., a_N seperated by a space. The second line contains b_1, b_2, ..., b_N seperated by a space.

It can be shown that there always exists a solution for any input satisfying the constraints.

Sample Input 1

2
1 2

Sample Output 1

1 4
5 4

a_1 + b_1 = 6 and a_2 + b_2 = 8. So this output satisfies all conditions.

Sample Input 2

3
3 2 1

Sample Output 2

1 2 3
5 3 1

Sample Input 3

3
2 3 1

Sample Output 3

5 10 100
100 10 1

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);

LL BigMod(LL B,LL P,LL M){LL R=1;while(P>0){if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;}return R;}

#include<bits/stdc++.h>

using namespace std;
int ara[20005];
int A[20005],B[20005];
int main()
{

    int n;
    cin >> n;
    REP(i,n)cin >> ara[i];

    int a = 1;
    REP(i,n){
        A[i+1]=a;
        a+=40000;
    }
    int tar = 100000;
    REP(i,n)
    {
        int pos = ara[i];
        int mx = 1;
        REP(j,n)
        {
            if(j>pos){
                mx = max(mx,B[j+1]);
            }
        }
        B[pos] = max(tar,mx);
        tar = B[pos]+A[pos]+1;
    }
    REP(i,n)cout << A[i+1] << " ";
    cout << "\n";
    REP(i,n)cout << B[i+1] << " ";
    cout << "\n";


}