using namespace std ;
#include <bits/stdc++.h> /* #7th-Polygon */
const int N = 1 << 20 ;
int n , a[N] , b[N] ;
int GetBit(int mask)
{
for (int i = n ; i >= 0 ; --i)
if (mask & (1 << i))
return n - i ;
return n ;
}
int main()
{
ios::sync_with_stdio(false) ;
cout.tie(nullptr) ;
cin.tie(nullptr) ;
cin >> n ;
for (int i = 0 ; i < (1 << n) ; ++i)
cin >> a[i] ;
memcpy(b , a , sizeof(b)) ;
sort(b , b + (1 << n)) ;
for (int i = 0 ; i < (1 << n) ; ++i)
cout << GetBit(upper_bound(b , b + (1 << n) , a[i]) - b) << " " ;
return 0 ;
}