#include<bits/stdc++.h>
typedef long long ll;
#define endl "\n"
#define optimize() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define pb push_back
#define testcase ll t; cin>>t; while(t--)
using namespace std;
int main() {
  optimize();
  ll n;
  cin>>n;
  ll cnt = 0, ans = 0;
  for(ll i = 0; i < 1000000000; i++) {
    cnt += i;
    if (cnt >= n) {
      ans = i;
      break;
     
    }
  }
  cout<<ans<<endl;
}
//ABC_197_C_
//
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define reps(i,s,n) for(int i=s;i<n;++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 1e18;
    rep(i,1<<20)
    {
        ll bit = i;
        ll tmp = a[0];
        vector<ll> v;
        rep(j,n-1)
        {
            ll bit1 = bit & (1<<j);
            ll bit2 = bit & (1<<(j+1));

            if(bit1*2 == bit2)
            {
                tmp = tmp | a[j+1];
            }
            else
            {
                v.emplace_back(tmp);
                tmp = a[j+1];
            }
        }
        v.emplace_back(tmp);
        ll now = 0;
        for(auto vi:v) now = now ^ vi;
        ans = min(ans,now);  
    }
    cout << ans << endl;
    return 0;
}