/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int xo=0;
for(int i=0;i<n;i++)
{
xo^=a[i];
}
int pos=0;
int temp=xo;
while((temp&1)!=1)
{
pos++;
temp=temp>>1;
}
int mask=(1>>pos);
int x=0,y=0;
for(int i=0;i<n;i++)
{
if(mask&a[i])
{
x=x^a[i];
}
}
y=x^xo;
cout<<y<<" "<<x;
return 0;
}