//# pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using ll=long long; using ld=long double; using ull=unsigned long long; typedef pair P; #define vec vector #define pb emplace_back #define fs first #define sc second #define pcnt __builtin_popcountll #define rep(i,n) for(ll i=0;i<(n);i++) #define rng(i,s,t) for(ll i=s;i bool inline chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template bool inline chmax(T& a, T b){if(a < b){a = b; return true;} return false;} template void printvec(itr begin, itr end) { for (itr p = begin; p < end; p++){ if(p!=begin)cout<<" "; cout << *p; } cout << endl; } template T makevec(T value) {return value;} template 0), int> = 0> auto makevec(std::size_t n, Args... args) { auto inner = makevec(args...); return std::vector(n, inner); } #include "atcoder/modint.hpp" using namespace atcoder; typedef modint998244353 mint; const ll mod=998244353; int main(){ ll n; cin>>n; veca(n); rep(i,n) cin>>a[i]; vec>b(n),c(n); rep(i,n){ veccnt(n); cnt[i]=1; c[i].push_back(a[i]); ll cur=a[i]; rep(j,n-1){ ll mx=-1,idx=-1; rep(k,n){ if(cnt[k]==0&&chmax(mx,a[k]^cur))idx=k; } cnt[idx]=1; c[i].push_back(a[idx]); b[i].push_back(a[idx]^cur); cur=a[idx]; } } vec,vec>> res; rep(i,n){ res.push_back({b[i],c[i]}); } auto ans=*max_element(all(res)); printvec(all(ans.second)); }