////////////// VATSAL AGARWAL ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef id : vatsal38 ////////////////////////
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(a,b,c) for(ll i=a;i<=b;i+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v) v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order /// find kth smallest by passing k-1
#define ook order_of_key //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
void AcDegaYe()
{
ll n;
cin>>n;
vector<ll> a;
a.pb(-1);
inpvec(a,n);
ll pre[n+1];
ll suf[n+1];
for(ll i=1;i<=n;i++)pre[i]=(pre[i-1]|a[i]);
for(ll i=n;i>=1;i--)suf[i]=(suf[i+1]|a[i]);
ll idx=1;
ll ans=INT_MIN;
for(ll i=1;i<=n;i++)
{
ll x=a[i];
ll y=(pre[i-1]|suf[i+1]);
if((x|y)-y>ans)
{
ans=(x|y)-y;
idx=i;
}
}
//cout(idx);
cout<<a[idx]<<" ";
for(ll i=1;i<=n;i++)if(i!=idx)cout<<a[i]<<" ";
}
int main()
{
fastio
//ll t;
//cin>>t;
ll t=1;
while(t--)
{
AcDegaYe();
}
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
Ci8vLy8vLy8vLy8vLy8vICAgICAgVkFUU0FMIEFHQVJXQUwgICAgICAgLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCi8vLy8vLy8vLy8vLy8vIENvZGVmb3JjZXMgaWQgOiB3YXJoZWFkMzggLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCi8vLy8vLy8vLy8vLy8vIENvZGVjaGVmICAgaWQgOiB2YXRzYWwzOCAgLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vIAoKCiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgojaW5jbHVkZSA8ZXh0L3BiX2RzL2Fzc29jX2NvbnRhaW5lci5ocHA+IAojaW5jbHVkZSA8ZXh0L3BiX2RzL3RyZWVfcG9saWN5LmhwcD4gCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIG5hbWVzcGFjZSBfX2dudV9wYmRzOwp0eXBlZGVmIHRyZWU8aW50LCBudWxsX3R5cGUsIGxlc3M8aW50PiwgcmJfdHJlZV90YWcsIHRyZWVfb3JkZXJfc3RhdGlzdGljc19ub2RlX3VwZGF0ZT4gcGJkczsKI2RlZmluZSBsbCBsb25nIGxvbmcgaW50CiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZyBpbnQKI2RlZmluZSBsZCBsb25nIGRvdWJsZQojZGVmaW5lIGVuZGwgJ1xuJwojZGVmaW5lIGxvb3AoYSxiLGMpIGZvcihsbCBpPWE7aTw9YjtpKz1jKQojZGVmaW5lIGludGFycihhcnIsbikgbGwgYXJyW25dO2ZvcihsbCBpPTA7aTxuO2krKyljaW4+PmFycltpXQojZGVmaW5lIGl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