/**
 * @author yuzining
 * @date 2021/03/27 20:12
 */

#ifdef local
#include "D:\VSCODE\debug.hpp"
#else
#include <bits/stdc++.h>
#define DEBUG(...) do { } while (0)
const int _______ = []() { std::ios::sync_with_stdio(false), std::cin.tie(nullptr); return 0; }();
#endif

int main() {
  int n; std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  int ans = INT_MAX;
  for (int i = 0; i < (1 << n); i++) {
    int cur = 0, tmp = 0;
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        cur ^= tmp;
        tmp = 0;
      }
      tmp |= a[j];
    }
    cur ^= tmp;
    ans = std::min(ans, cur);
  }
  std::cout << ans << '\n';
}
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#ifndef JHELPER1_COMMON_H
#define JHELPER1_COMMON_H

#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

typedef long long ll;
using namespace std;

constexpr ll MOD = 1000 * 1000 * 1000 + 7;

#define READ_VEC(v) for(auto &e: v){in >> e;}
#define READ_PAIR_VEC(v) for(auto &e: v){in >> e.first >> e.second;}
#define ALL(c) std::begin(c), std::end(c)

#endif //JHELPER1_COMMON_H


class CORXOR {
public:
  void solve(std::istream& in, std::ostream& out) {
    int N;
    in >>N;
    vector<int> A(N);
    READ_VEC(A);

    ll mi = 1000'000'000'000L;
    for (int i = 0; i < (1<<(N-1)); ++i) {
      ll tot = 0;
      ll lo = 0;
      for (int j = 0; j < N; ++j) {
        lo |= A[j];

        if (j == N-1 || i & (1<<j)) {
          tot ^= lo;
          lo = 0;
        }
      }
      mi = min(mi, tot);
    }
    out << mi << endl;
  }
};


int main() {
  CORXOR solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
