Buggy python submission (verdict: Time Limit Exceeded):
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))


lst=set([P[0]])
for i in range(1,N):
    for m in lst:
        B[m]-=1
    lst.add(P[i])

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))


Fixed submission:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))
ruiA=[]
ruiB=[]


#lst=set(P[1:])
count=1
for i in range(0,N)[::-1]:
    B[P[i]]-=count
    """for m in lst:
        B[m]-=1
    lst.add(P[i])"""
    count+=1

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))

Buggy python submission (verdict: Time Limit Exceeded):
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))


lst=set(P[1:])
for i in range(1,N):
    for m in range(N):
        if not m in lst:
            B[m]-=1
    lst.remove(P[i])

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))


Fixed submission:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))
ruiA=[]
ruiB=[]


#lst=set(P[1:])
count=1
for i in range(0,N)[::-1]:
    B[P[i]]-=count
    """for m in lst:
        B[m]-=1
    lst.add(P[i])"""
    count+=1

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))

Buggy python submission (verdict: Time Limit Exceeded):
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))


lst=set(P[1:])
for i in range(1,N):
    for m in range(N):
        A[m]+=1
        if not m in lst:
            B[m]-=1
    lst.remove(P[i])

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))


Fixed submission:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))
ruiA=[]
ruiB=[]


#lst=set(P[1:])
count=1
for i in range(0,N)[::-1]:
    B[P[i]]-=count
    """for m in lst:
        B[m]-=1
    lst.add(P[i])"""
    count+=1

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))