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)

#include <bits/stdc++.h>
/*
                                                 ......((.....
   `  `  `  `  `  `  `  `  `  `  `  `  `  ` ..+zOwwuzuzzzuzzvzzzzO+-.   `  `  `  `  `  `  `  `  `
                                         .(ztOwXZuuuuuuZuuuuZZuZuuuuzvw+..
    `   `    `   `    `   `    `   `   .1lztOwuZZZZZZZyZyZZyZZXyyZZZuuuuuzw+.   `    `   `    `  `
                                     .+ztrrwwuuXXXyyyyyyyyVyVVVVyWyyZZZZuuuzzw.
           `        `        `    ` (==lttwwV=_..,`?WyyyyVyyVVVVyyyyZXyZZZuuXuzw&. `        `
   `  `        `        `         .?==lltrvC `` W#N..yyyyyyVVVVyyZyyyXyyyZZZZXuuuO-     `
        `        `        `    ` .??=lltrrw ,  .dH# .ZZyVyZXyyyyyyyZZyyZZXZyZyXZZ0Ol       `   `  `
  `       `  `     `  `     `   .??==zlOOZO.(HMM#" .wZZuZyyZXyyZZyyyyyZZyyyXXVyZuuuOl
     `                         .??<<<~<<~___. ` .-?OOVZOXXXWZZyZXyZZyZZXyWVfWYTUuuuXO>  `
                `        `    .<<~~~~........... ..._~__<~?<zZZuuuuZXuuZZyXC.(QJ-1uuOl.    `  `  `
      `  `  `      `  `     `.~~~~~~.~~~.........``....`....__?777TVVXXZXuI.`..dN.OuOl;
  `           `             .~~~~~~~~~~~~~~..................__...__~~<zwzI.x..JN%(vtl{  `   `
    `  `  `     `   `  `   .~~~.~~~~~.~~~~~~....~~~..~..__~..........._~<?C_(MNNB_Jwtl>        `  `
             `    `      ` (~~~~~..._~..~.~.~.~.....~~~.....~.~~..~....~~~~~~~_-.Jzrll>   `
                         .wz<:~.~....~~~~...~~......~......._~._~.~_._..~.~~~~:<?zzOll>      `
  `  `  `  `    `   ` `.wvzI<_....._~~.....~..~~~.....~..._.........~~~~~~~~~~~~::<1zt{        `  `
                      .XuXWk<~.._-~~~~~.~~~....~.~.~........~~_...~~_~~~~~~~~~~~~~:::<~  `
                     .XXWpkR<_~~~~~~~~~~~.~..~....~~~~~......~~..~~~.~~~~~~~:~~~:::::;<
                     .fpkqqK<<~~~~.~~~_.....~..~..~....~.~....~..~~.~~~~.~~~~~::~:::;;;.
                      XkqqmH<_~_.~~~_.._.......~~.~~..~.~.~~~.~~.~~.~~~~~~~~~~~:~::;;;><
                      .WqmmHv<(::~~~__....~~~~~~~~~~~~~~~~~.~.......~~~~~.~~~:~~:::;>>><
                       (qmqHzz>:~~~__~~......~__....~...~.~~~~.....~~~.~~~~~~~:~:::>>>><
                        WqHHHOz++<:::~~......-_.~~~~~~~~..~~~~~~~~~~~.~.~~~:::::~(:>??<`
                        .HHkkHkz<<<<;:<~__~~~~~~~~~...~~~~~~~~_~~~~~~~~::~::~~::~(<+??!
                         (HppHHHkz><<~~~~~~~~~~:~~~~~~___~:~~::~::::::::~:::_~~::(??l!
                          zyWHUXW$~_<::<?-(___.~~~:_::::_-~~~_~~~~<:::::~~::::::<+?>
                          JwZrwuZ$``` _(<<><;<+((_~~~:~<:_~~~~~~~~~_~::::::::_(>??<
                         .tlllwuX6_`  _(HWkkkkdedA++++<<<;-___~::_:::~~~:::(<<+1z?
                        `(lllOvzzw-    (bWVVVVfffpWfXXwOozI+;<<<;<;<_(:(<<++zzOv!
                         tlztwuzuvI_``` OVyyyyyyWWyWWffpfpWw++<<<<;<++++1xOOlv!
                        ,tltwwrzwrrG-  `(WWyyyyyZZZZyZZZZZZyyWf<_` -_+WHWfWyZn
                        tttrrrrrrrrrro-. ?WyZZuuuuuuuZZZZZZZWY~```._(HqHyVWyZZl
                       .ttttrvrrrrrrrrXk..JyuuuuXrzuuuuuuZZV>````-(dHkHWXUZZZXZ
                      `(rttrrrrtOOttrrzXZZyWXZuXrrzzzuuuzXC`   -(JuXWHWZuuZuzv}
                       zrrttrtttttttrvvzuuuZZuvvrvwzzzzzv! ..(+wzuzXWWXWuuuzz2
                       vrrrtrrrrtrrrrtrvvzzuuUuvvvvvrzuXGuwXuzzvvzzuykWWuuuzz'
                       vrrrttrrrvrrrttrrrrwwvvvrrrvwuuC1+((((-(J_zzuyHWyZXuu\
                       zrrrrrtrrrrrrrrrrttrtrrrrrvrrrCJ~~~(-~~~z(uzuXqHHWZV^
                       uzrrrrrrrrrrtrrrrrrrrrrrrrrwrw>$~._+<~~_r(uuuXWf??`
                       OuurrrrrrrrrrrrrrvrrrrtttrrrrI(l~~(1_~~(>(vuZZy:
                       ,uuzvrrrrrrrrrrrrrrrrrOtrtttt>J~~~_<~~~J_wvwuu0
                        XZuvzvrrrrrrrrrrrrrrrrrrtttr<v~~~_<<~_$(zwuuZ:
                        ,yZuzzzzzrrrrrrrrrvrrrttrrrZ_r~:(C-:(J<juuZZr
                         jWZuuuzzzzvvrrrrrrrrrrrrrrI(C::+<<~.z(wuuZV
                         .WfWXuuuuuzvvvrrrrrrrrrrrw>Z::<(~~_(t(uXZ2
                          ,pWWWyyXZuuzzvvvzzzXvvrvZ(C+++i(++J+dyyY
                           jppbWWVyXZXuuuzzuuuuzzzzzzzzzuuuZZXXX^
                            7bbpWHbWWWWyyXXXZXZZXXXuXuuuuXyyVX=
                             .4bbbpkkkHWWWWfWWXXXVyXyyyVVWWWf
                              .HHbkbbkkkqHHHHHHkbWWppppWfffW!
                              .Hg@M@HH@HHHH@MHbbppffVVVVfff\
                              Jkmgg@@@@@@HHHMMNkpffffffpWKW:
                            `.Wkqqmqggg@@@HHH@H@@@@gg@@gqHZ!
                             dWWWHkHkqHqmmqfHHHg@gHggHmkHHW!
                              UUyWHWWWWWUUV^(HHWHgHqqHHHWWr
                                 .?!!!!       ???TZ7TV777^
*/
using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
	return a * b / my_gcd(a, b);	
}

template<typename T> struct UF {
    vector<int> par;
    vector<T> sz;

    UF(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    vector<int> A(n), B(n);
    A[0] = 40000;
    B[0] = 40000;
    rep(i, n - 1) {
        A[i + 1] = A[i] + 1;
        B[i + 1] = B[i] - 1;
    }

    rep(i, n) {
        A[p[i] - 1] += i + 1;
    }

    rep(i, n) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    rep(i, n) {
        if (i) cout << " ";
        cout << B[i];
    }
    cout << endl;

    return 0;
}