#include <iostream>

using namespace std;

int main(){
  long int N; cin >> N;
  long int sum = 0;
  int day = 0;
  do{
    sum += day++;
  }while(sum < N);
  
  cout << day-1 << endl;
  
  return 0;
}
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
#define FOR(i,j,k) for(int i=j; i<=k; ++i)
inline int read (void) {
	int x = 0, f = 1, ch = getchar();
	while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
	while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, ans, a[25];
void dfs (int x, int Xor, int Or) {
	if(x > n) {
		ans = min(ans, Xor ^ Or);
		return ;
	}
	dfs (x+1, Xor, Or | a[x]);
	dfs (x+1, Xor ^ Or, a[x]);
}
int main (void) {
	n = read(); ans = (1 << 31) - 1;
	FOR(i,1,n) a[i] = read();
	dfs (1, 0, 0);
	printf("%d\n", ans);
	return 0;
}