#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using pint = pair<int,int>;


int main()
{
	int N;cin >> N;
	int m = N - 1;
	vector<int> A(N);
	for(auto &i: A) cin >> i;
	int ans = 1<<30;

	for(int bit = 0; bit < (1<<m); bit++) {
		vector<int> b = {A[0]};
		for(int i = 0; i < N - 1; i++) {
			if((1 << i) & bit) {
				b.push_back(0);
			}
			b.back() |= A[i + 1];
		}

		int sum = accumulate(b.begin(), b.end(), 0, [](int x, int y){return (x xor y);});

		ans = min(ans, sum);
	}

	cout << ans << endl;


}

#include<bits/stdc++.h>

#define all(k) k.begin(),k.end()

#define repk(i,a, n) for(int i=a;i<=n;i++)
#define rep(i,a, n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define ll  long long
#define ull unsigned long long
#define pci pair<int,int>
#define vc vector<char>
#define vs vector<set<pi>>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vb vector<bool>
#define vpc vector<pci>
#define vvc vector<vc>
#define mi map<int,int>
#define mset map<string,set<char>>
#define umap unordered_map
#define int int64_t
using namespace std;
#define fi first
#define se second
#define mod 1000000007

void sol()
{ int n;
  cin >> n;
  vi a(n);
  rep(i,0,n)cin>>a[i];

  auto deep = [&](auto && deep, int i, int x, int o) -> int {
    if (i == n) return x ^ o;
    return min(deep(deep, i + 1, x, o | a[i]), deep(deep, i + 1, x ^ o, a[i]));
  };
  cout << deep(deep, 0, 0, 0);
}


int32_t main() {

int t=1;
// for(cin>>t;t;t--)
sol();
  return 0;
}
