import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    int n;
    scan(n);
    auto p = readln.split.to!(int[]);

    auto a = new int[](n);
    auto b = new int[](n);
    foreach (i ; 0 .. n) {
        a[i] = (i + 1) * (n + 1);
        b[n - 1 - i] = (i + 1) * (n + 1);
    }

    auto aim = new int[](n + 1);
    auto bim = new int[](n + 1);

    p[] -= 1;
    foreach (pi ; p[0 .. $-1]) {
        aim[pi + 1]++; aim[n]--;
        bim[0]++; bim[pi]--;
    }
    foreach (i ; 0 .. n) {
        aim[i + 1] += aim[i];
        bim[i + 1] += bim[i];
    }

    foreach (i ; 0 .. n) {
        a[i] += aim[i];
        b[i] += bim[i];
    }

    debug {
        writeln(aim);
        writeln(bim);
        writeln(a);
        writeln(b);
    }

    foreach (i ; 0 .. n - 2) {
        a[p[i]] -= (n - 2 - i);
    }

    writefln("%(%s %)", a);
    writefln("%(%s %)", b);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
