#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[31],f[31][31];long long ans=1e15;
void dfs(int las,int sum)
{
	if(las==n)
	{
		ans=min(ans,1ll*sum);
		return;
	}
	for(int i=las+1;i<=n;i++)
		dfs(i,sum^f[las+1][i]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			f[i][j]=f[i][j-1]|a[j];
	dfs(0,0);
	printf("%lld",ans);
}
        #include<bits/stdc++.h>
         
        using namespace std;
         
        #define FOR(i,a,b) for(int i = (a); i < (b); i++)
        #define RFOR(i,a,b) for(int i = (a) - 1; i>=(b);i--)
        #define rep(i,n) FOR(i,0,n)
        #define PB push_back
        #define SZ(a) (int)a.size()
        #define ALL(a) a.begin(), a.end()
        #define FILL(a, value) memset(a, value, sizeof(a))
        #define IOS ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0);
         
         
        typedef  long long LL ;
        typedef  vector<int > VI ;
        typedef vector<LL > VL;
        typedef pair<int,int > PII;
        typedef pair<LL,LL> PLL;
         
        const LL LINF = (LL)1e18 +47;
        const int INF =  (int)(1 << 30) + 100 ;
        const int MOD =(int)1e9 + 7 ;
        const int modulo = 998244353;
        const int nax =  3 * (int)1e5 + 10;
        const double EPS = 1e-7;
        const double PI = acos(-1.0);

        int a[nax]; 
        int main()
        {
           #ifndef ONLINE_JUDGE
          freopen("input.txt", "r", stdin);                               
          freopen("output.txt", "w", stdout);
          #endif
          IOS;
          int n;
          cin >> n ;
          rep(i,n)cin >> a[i]; 
          int ans = INF; 
          for(int mask =1; mask < (1 << n); mask++)
          {
              vector<int > vec; 
              int orr = 0; 
              rep(i,n)
              {
                orr|=a[i];
                if(mask &(1 << i))
                {
                   vec.PB(orr);
                   orr = 0;  
                }
              }
              if(orr!=0)vec.PB(orr);
              int xr = 0;
              for(auto x : vec)xr^=x;
              ans = min(ans,xr); 
          }
          cout << ans << '\n'; 

          
        }
