/*
*@author: percation
*#time:2021.04.22
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 39;
int tree[N];
int n;
void build(int x){
if(n < x)
return ;
build(x << 1);
build(x << 1 | 1);
cin >> tree[x];//后序遍历放后面
}
int main(){
cin >> n;
build(1);
for(int i = 1; i <= n; i++){
if(i != n){
cout << tree[i] << " ";
}
else
cout << tree[i] << endl;
}
return 0;
}