那就或呗......
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
int n;
cin>>n;
ll ans=0;
ll tmp=0;
for(int i=0;i<n;i++){
ll a;
cin>>a;
tmp|=a;
}
ans+=tmp;
tmp=0;
for(int i=0;i<n;i++){
ll a;
cin>>a;
tmp|=a;
}
ans+=tmp;
cout<<ans<<endl;
}