#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, p, a[20010], b[20010];
int main(){
	cin >> n >> p;
	rep(i, n)a[i] = (i + 1) * 30000;
	for (int i = n;i > 0;i--)b[n - i] = i * 30000;
	rep(i, n - 1) {
		cin >> p;
		a[p - 1] += i + 1;
	}
	rep(i, n)cout << a[i] << " ";
	cout << endl;
	rep(i, n)cout << b[i] << " ";
	cout << endl;
	getchar();getchar();
	return 0;
}