試しに図を書いてみた回。

solution

これを:

こうすると:

こうなる:

implementation

#!/usr/bin/env python3
n = int(input())
ps = list(map(int,input().split()))
imos = [None] * n
for i, p in enumerate(ps):
    imos[p-1] = i
a = [ 0 ]
b = [ 0 ]
for i in range(n):
    a += [ a[-1] + 1 + imos[i]     ]
    b += [ b[-1] + 1 + imos[n-i-1] ]
print(*a[1:])
print(*reversed(b[1:]))