#include
using namespace std;
int main() {
short n;
short * a;
cin >> n;
if (n < 0)
return 1;
else
a = new short[n];
for (short i = 0; i < n; i++)
cin >> a[i];
for (short i = 0; i < n; i += 3)
cout << max(max(a[i], a[i+1]), a[i+2]) << " ";</p>
cout << endl;</p>
for (short i = 0; i < n; i++)
cout << a[i] << " ";</p>
delete[] a;
return 0;
}