#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t;

#define bit(i) (1<<(i))
#define isset(n,i) (n&bit(i))
#define cbi(n,i) n -= bit(i)

vector<bool> B;
int n;

bool roznicuj() {
	int mx=0;
	REP(i,n) mx=max(mx,t[i]);
	int mbit;
	for(int bi=0; bi<=30; ++bi)
		if(isset(mx,bi))
			mbit = bi;
	int cnt=0;
	//dprintf("%d\n", mbit);
	REP(i,n)
		if(isset(t[i],mbit))
			++cnt;
	if(cnt == n) {
		REP(i,n) t[i] -= bit(mbit);
		return true;
	}
	REP(i,n)
		if(isset(t[i],mbit))
			B[i] = true;
	return false;
}

int main() {
	SC(n);
	t.resize(n+1,0);
	B.resize(n+1,false);
	REP(i,n) SC(t[i]);

	int mbit;
	while(roznicuj());
	dptab(ALL(t));

	int mxor = 0;
	REP(i,n) if(B[i]) {
		dprintf("%d\n", i);
		int maxt = -1;
		for(int j=i+1; j<=n && !B[j]; ++j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[i]);
			}
		maxt = -1;
		for(int j=i-1; j>0 && !B[j]; --j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[i]);
			}
	}

	printf("%d\n", mxor);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t,l,p;

int do_range(int a, int b) {
	if(b - a < 2) return 0;

	int k = a;
	while(k && p[k]<=b && t[p[k]] > t[k])
		k = p[k];
	dprintf("[%d %d %d]\n", a, k, b);

	int mxor = 0;
	for(int i=k-1; t[i]; i=l[i])
		mxor = max(mxor, t[k]^t[i]);
	for(int i=k+1; t[i]; i=p[i])
		mxor = max(mxor, t[k]^t[i]);

	mxor = max(mxor, do_range(a,k-1));
	mxor = max(mxor, do_range(k+1,b));
	return mxor;
}

int main() {
	GET(n);
	t.resize(n+2,0), l.resize(n+1,0), p.resize(n+1,0);
	REP(i,n) SC(t[i]);
	REP(i,n) {
		int j = i-1;
		while(j && t[j]<t[i])
			j = l[j];
		l[i] = j;
	}
	for(int i=n; i; --i) {
		int j = i==n? 0 : i+1;
		while(j && t[i]>t[j])
			j = p[j];
		p[i] = j;
	}
	dptab(ALL(l));
	dptab(ALL(t));
	dptab(ALL(p));

	printf("%d\n", do_range(1,n));
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t;

#define bit(i) (1<<(i))
#define isset(n,i) (n&bit(i))
#define cbi(n,i) n -= bit(i)

set<int> S;
int n;

bool roznicuj() {
	S.clear();
	int mx=0;
	REP(i,n) mx=max(mx,t[i]);
	int mbit;
	for(int bi=0; bi<=30; ++bi)
		if(isset(mx,bi))
			mbit = bi;
	int cnt=0;
	REP(i,n)
		if(isset(t[i],mbit))
			++cnt;
	if(cnt == n) return true;
	REP(i,n)
		if(isset(t[i],mbit))
			S.insert(i);
	return false;
}

int main() {
	SC(n);
	t.resize(n+1,0);
	REP(i,n) SC(t[i]);

	int mbit;
	while(roznicuj());

	int mxor = 0;
	for(set<int>::iterator it=S.begin(); it!=S.end(); ++it) {
		int maxt = 0;
		for(int j=*it+1; j<=n && !S.count(j); ++j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[*it]);
			}
		maxt = 0;
		for(int j=*it-1; j>0 && !S.count(j); --j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[*it]);
			}
	}

	printf("%d\n", mxor);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t;

#define bit(i) (1<<(i))
#define isset(n,i) (n&bit(i))
#define cbi(n,i) n -= bit(i)

set<int> S;
int n;

bool roznicuj() {
	S.clear();
	int mx=0;
	REP(i,n) mx=max(mx,t[i]);
	int mbit;
	for(int bi=0; bi<=30; ++bi)
		if(isset(mx,bi))
			mbit = bi;
	REP(i,n)
		if(isset(t[i],mbit))
			S.insert(i);
	return S.sz==n;
}

int main() {
	SC(n);
	t.resize(n+1,0);
	REP(i,n) SC(t[i]);

	int mbit;
	while(roznicuj());

	int mxor = 0;
	for(set<int>::iterator it=S.begin(); it!=S.end(); ++it) {
		int maxt = 0;
		for(int j=*it+1; j<=n && !S.count(j); ++j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[*it]);
			}
		maxt = 0;
		for(int j=*it-1; j>0 && !S.count(j); --j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[*it]);
			}
	}

	printf("%d\n", mxor);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t,l,p;

int do_range(int a, int b) {
	if(b - a < 2) return 0;

	int q = a, Q=b, k=0;
	while(true) {
		if(!p[q] || b<p[q]) {
			k = q;
			break;
		}
		if(!l[Q] || l[Q]<a) {
			k = Q;
			break;
		}
		q = p[q];
		Q = l[Q];
	}

	dprintf("[%d %d %d]\n", a, k, b);

	int mxor = 0;
	for(int i=k-1; t[i]; i=l[i])
		mxor = max(mxor, t[k]^t[i]);
	for(int i=k+1; t[i]; i=p[i])
		mxor = max(mxor, t[k]^t[i]);

	mxor = max(mxor, do_range(a,k-1));
	mxor = max(mxor, do_range(k+1,b));
	return mxor;
}

int main() {
	GET(n);
	t.resize(n+2,0), l.resize(n+1,0), p.resize(n+1,0);
	REP(i,n) SC(t[i]);
	REP(i,n) {
		int j = i-1;
		while(j && t[j]<t[i])
			j = l[j];
		l[i] = j;
	}
	for(int i=n; i; --i) {
		int j = i==n? 0 : i+1;
		while(j && t[i]>t[j])
			j = p[j];
		p[i] = j;
	}
	dptab(ALL(l));
	dptab(ALL(t));
	dptab(ALL(p));

	printf("%d\n", do_range(1,n));
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t;

#define bit(i) (1<<(i))
#define isset(n,i) (n&bit(i))
#define cbi(n,i) n -= bit(i)

set<int> S;
int n;

bool roznicuj() {
	S.clear();
	int mx=0;
	REP(i,n) mx=max(mx,t[i]);
	int mbit;
	for(int bi=0; bi<25; ++bi)
		if(isset(mx,bi))
			mbit = bi;
	int cnt=0;
	REP(i,n)
		if(isset(t[i],mbit))
			S.insert(i);
	return S.sz==n;
}

int main() {
	SC(n);
	t.resize(n+1,0);
	REP(i,n) SC(t[i]);

	int mbit;
	while(roznicuj());

	int mxor = 0;
	for(auto it=S.begin(); it!=S.end(); ++it) {
		int maxt = 0;
		for(int j=*it+1; j<=n && !S.count(j); ++j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[*it]);
			}
		maxt = 0;
		for(int j=*it-1; j>0 && !S.count(j); --j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[*it]);
			}
	}

	printf("%d\n", mxor);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t;

#define bit(i) (1<<(i))
#define isset(n,i) (n&bit(i))
#define cbi(n,i) n -= bit(i)

vector<bool> B;
int n;

bool roznicuj() {
	int mx=0;
	REP(i,n) mx=max(mx,t[i]);
	int mbit;
	for(int bi=0; bi<=30; ++bi)
		if(isset(mx,bi))
			mbit = bi;
	int cnt=0;
	REP(i,n)
		if(isset(t[i],mbit))
			++cnt;
	if(cnt == n) return true;
	REP(i,n)
		if(isset(t[i],mbit))
			B[i] = true;
	return false;
}

int main() {
	SC(n);
	t.resize(n+1,0);
	B.resize(n+1,false);
	REP(i,n) SC(t[i]);

	int mbit;
	while(roznicuj());

	int mxor = 0;
	REP(i,n) if(B[i]) {
		int maxt = 0;
		for(int j=i+1; j<=n && !B[j]; ++j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[i]);
			}
		maxt = 0;
		for(int j=i-1; j>0 && !B[j]; --j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[i]);
			}
	}

	printf("%d\n", mxor);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t;

#define bit(i) (1<<(i))
#define isset(n,i) (n&bit(i))
#define cbi(n,i) n -= bit(i)

vector<bool> B;
int n;

bool roznicuj() {
	int mx=0;
	REP(i,n) mx=max(mx,t[i]);
	int mbit;
	for(int bi=0; bi<=30; ++bi)
		if(isset(mx,bi))
			mbit = bi;
	int cnt=0;
	//dprintf("%d\n", mbit);
	REP(i,n)
		if(isset(t[i],mbit))
			++cnt;
	if(cnt == n) {
		REP(i,n) t[i] -= bit(mbit);
		return true;
	}
	REP(i,n)
		if(isset(t[i],mbit))
			B[i] = true;
	return false;
}

int main() {
	SC(n);
	t.resize(n+1,0);
	B.resize(n+1,false);
	REP(i,n) SC(t[i]);

	int mbit;
	while(roznicuj());
	dptab(ALL(t));

	int mxor = 0;
	REP(i,n) if(B[i]) {
		dprintf("%d\n", i);
		int maxt = -1;
		for(int j=i+1; j<=n && !B[j]; ++j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[i]);
			}
		maxt = 0;
		for(int j=i-1; j>0 && !B[j]; --j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[i]);
			}
	}

	printf("%d\n", mxor);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,1,(n)+1)
typedef vector<int> vi;
#define pb push_back
typedef pair<int,int> pii;
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
#define INF 1000000001
#define sz size()
#define VAR(n,v) typeof(v) n=(v)
#define ALL(t) t.begin(),t.end()
#define SC(a) scanf("%d", &a)
#define GET(a) int a; SC(a)
#define ISDEBUG 0
#define dprintf(...) if(ISDEBUG) {printf("\033[31m"); printf(__VA_ARGS__); printf("\033[0m");}
template <class It> void dptab(It b, It e, const char* f="%d ") {if(ISDEBUG) {for(It it=b; it!=e; ++it) dprintf(f, *it); dprintf("\n"); }}

vi t;

#define bit(i) (1<<(i))
#define isset(n,i) (n&bit(i))
#define cbi(n,i) n -= bit(i)

set<int> S;
int n;

bool roznicuj() {
	S.clear();
	int mx=0;
	REP(i,n) mx=max(mx,t[i]);
	int mbit;
	for(int bi=0; bi<25; ++bi)
		if(isset(mx,bi))
			mbit = bi;
	int cnt=0;
	REP(i,n)
		if(isset(t[i],mbit))
			S.insert(i);
	return S.sz==n;
}

int main() {
	SC(n);
	t.resize(n+1,0);
	REP(i,n) SC(t[i]);

	int mbit;
	while(roznicuj());

	int mxor = 0;
	for(set<int>::iterator it=S.begin(); it!=S.end(); ++it) {
		int maxt = 0;
		for(int j=*it+1; j<=n && !S.count(j); ++j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[*it]);
			}
		maxt = 0;
		for(int j=*it-1; j>0 && !S.count(j); --j)
			if(t[j] > maxt) {
				maxt = t[j];
				mxor = max(mxor, t[j]^t[*it]);
			}
	}

	printf("%d\n", mxor);
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#define N 100010
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,an;
int f[N][20],id[N],a[N];
inline bool cc1(const int &A,const int &B) {
	return a[A]<a[B];
}
inline void work() {
	For(i,1,n) id[i]=i;
	sort(id+1,id+n+1,cc1);
	memset(f,0,sizeof(f));
	For(i,1,n) f[i][0]=a[i];
	For(j,1,19)For(i,1,n-(1<<j)+1) f[i][j]=max(f[i][j-1],f[i+(1<<j-1)][j-1]);
	For(i,1,n) {
		int A=id[i],B=a[A],r=A;
		for (j=19;j>=0;j--) if (f[r][j]==B) r+=1<<j;
		if (r==A+1) continue;
		int l=A+1,s=0;
		for (k=30;k>=0;k--) {
			int mid=l;
			for (j=19;j>=0;j--) if (mid+(1<<j)<=r&&!(f[mid][j]>>k&1)) mid+=1<<j;
			if (B>>k&1) {
				if (l<mid) {
					s|=1<<k;
					r=mid;
				}
			} else {
				if (mid<r) {
					s|=1<<k;
					l=mid;
				}
			}
		}
		an=max(an,s);
	}
}
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	work();
	For(i,1,n/2) swap(a[i],a[n-i+1]);
	work();
	printf("%d\n",an);
	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <map>
#define N 100010
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,an;
int f[N][20],id[N],a[N];
map<int,int> Map;
inline bool cc1(const int &A,const int &B) {
	return a[A]<a[B];
}
inline void work() {
	For(i,1,n) id[i]=i;
	sort(id+1,id+n+1,cc1);
	memset(f,0,sizeof(f));
	For(i,1,n) f[i][0]=a[i];
	For(j,1,19)For(i,1,n-(1<<j)+1) f[i][j]=max(f[i][j-1],f[i+(1<<j-1)][j-1]);
	For(i,1,n) {
		int A=id[i],B=a[A],r=A;
		for (j=19;j>=0;j--) if (f[r][j]&&f[r][j]<=B) r+=1<<j;
		if (r==A+1) continue;
		int l=A+1,s=0;
		for (k=30;k>=0;k--) {
			int mid=l;
			for (j=19;j>=0;j--) if (mid+(1<<j)<=r&&!(f[mid][j]>>k&1)) mid+=1<<j;
			if (B>>k&1) {
				if (l<mid) {
					s|=1<<k;
					r=mid;
				}
			} else {
				if (mid<r) {
					s|=1<<k;
					l=mid;
				}
			}
		}
		an=max(an,B^a[l]);
	}
}
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,n) {
		if (Map.count(a[i])) {
			printf("fuck\n");
		}
		Map[a[i]]=1;
	}
	work();
	For(i,1,n/2) swap(a[i],a[n-i+1]);
	work();
	printf("%d\n",an);
	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#define N 100010
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,an;
int f[N][20],id[N],a[N];
inline bool cc1(const int &A,const int &B) {
	return a[A]<a[B];
}
inline void work() {
	For(i,1,n) id[i]=i;
	sort(id+1,id+n+1,cc1);
	memset(f,0,sizeof(f));
	For(i,1,n) f[i][0]=a[i];
	For(j,1,19)For(i,1,n-(1<<j)+1) f[i][j]=max(f[i][j-1],f[i+(1<<j-1)][j-1]);
	For(i,1,n) {
		int A=id[i],B=a[A],r=A;
		for (j=19;j>=0;j--) if (f[r][j]&&f[r][j]<=B) r+=1<<j;
		if (r==A+1) continue;
		int l=A+1,s=0;
		for (k=30;k>=0;k--) {
			int mid=l;
			for (j=19;j>=0;j--) if (mid+(1<<j)<=r&&!(f[mid][j]>>k&1)) mid+=1<<j;
			if (B>>k&1) {
				if (l<mid) {
					s|=1<<k;
					r=mid;
				}
			} else {
				if (mid<r) {
					s|=1<<k;
					l=mid;
				}
			}
		}
		an=max(an,B^a[l]);
	}
}
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	work();
	For(i,1,n/2) swap(a[i],a[n-i+1]);
	work();
	printf("%d\n",an);
	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#define N 100010
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,r,an;
int g[N];
int main() {
	scanf("%d",&n);
	For(i,1,n) {
		scanf("%d",&k);
		for (;r&&g[r]<k;r--) {
			if (r>1) an=max(an,g[r]^g[r-1]);
			an=max(an,k^g[r]);
		}
		g[++r]=k;
	}
	for (;r>1;r--) an=max(an,g[r]^g[r-1]);
	printf("%d\n",an);
	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#define N 100010
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,an;
int f[N][20],id[N],a[N];
inline bool cc1(const int &A,const int &B) {
	return a[A]<a[B];
}
inline void work() {
	For(i,1,n) id[i]=i;
	sort(id+1,id+n+1,cc1);
	memset(f,0,sizeof(f));
	For(i,1,n) f[i][0]=a[i];
	For(j,1,19)For(i,1,n-(1<<j)+1) f[i][j]=max(f[i][j-1],f[i+(1<<j-1)][j-1]);
	For(i,1,n) {
		int A=id[i],B=a[A],r=A;
		for (j=19;j>=0;j--) if (f[r][j]==B) r+=1<<j;
		if (r==A+1) continue;
		int l=A+1,s=0;
		for (k=30;k>=0;k--) {
			int mid=l;
			for (j=19;j>=0;j--) if (mid+(1<<j)<=r&&!(f[mid][j]>>k&1)) mid+=1<<j;
			if (B>>k&1) {
				if (l<mid) {
					s|=1<<k;
					r=mid;
				}
			} else {
				if (mid<r) {
					s|=1<<k;
					l=mid;
				}
			}
		}
		an=max(an,B^a[l]);
	}
}
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	work();
	For(i,1,n/2) swap(a[i],a[n-i+1]);
	work();
	printf("%d\n",an);
	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#define N 100010
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,an;
int f[N][20],id[N],a[N];
inline bool cc1(const int &A,const int &B) {
	return a[A]<a[B];
}
inline void work() {
	For(i,1,n) id[i]=i;
	sort(id+1,id+n+1,cc1);
	memset(f,0,sizeof(f));
	For(i,1,n) f[i][0]=a[i];
	For(j,1,19)For(i,1,n-(1<<j)+1) f[i][j]=max(f[i][j-1],f[i+(1<<j-1)][j-1]);
	For(i,1,n) {
		int A=id[i],B=a[A],r=A;
		for (j=19;j>=0;j--) if (f[r][j]<=B) r+=1<<j;
		if (r==A+1) continue;
		int l=A+1,s=0;
		for (k=30;k>=0;k--) {
			int mid=l;
			for (j=19;j>=0;j--) if (mid+(1<<j)<=r&&!(f[mid][j]>>k&1)) mid+=1<<j;
			if (B>>k&1) {
				if (l<mid) {
					s|=1<<k;
					r=mid;
				}
			} else {
				if (mid<r) {
					s|=1<<k;
					l=mid;
				}
			}
		}
		an=max(an,B^a[l]);
	}
}
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	work();
	For(i,1,n/2) swap(a[i],a[n-i+1]);
	work();
	printf("%d\n",an);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <cstdlib>
using namespace std;

int n, a[100100], st[100100], last;

struct node
{
	node *l, *r;
	int low, high, mid;

	node()
	{
		l = NULL; r = NULL;
	}

	node(int _low, int _high)
	{
		l = NULL; r = NULL;
		low = _low; high = _high;
		mid = low / 2 + high / 2 + (low % 2 + high % 2) / 2;
	}

	void add(int val)
	{
		if (low == high) return;
		if (val <= mid)
		{
			if (l == NULL) l = new node(low, mid);
			l -> add(val);
		}
		else
		{
			if (r == NULL) r = new node(mid + 1, high);
			r -> add(val);
		}
	}

	int remove(int val)
	{
		if (low == high) return 1;
		if (val <= mid)
		{
			if (l -> remove(val)) l = NULL;
		}
		else
		{
			if (r -> remove(val)) r = NULL;
		}
		return l == NULL && r == NULL;
	}

	int get(int bit, int val)
	{
		if (low == high) return low;
		int curBit = val >> bit & 1;
		if (curBit)
		{
			if (l != NULL) return l -> get(bit - 1, val);
			return r -> get(bit - 1, val);
		}
		if (r != NULL) return r -> get(bit - 1, val);
		return l -> get(bit - 1, val);
	}
};

int main()
{
	//freopen("b.in", "r", stdin);
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);

	node root(0, (1 << 30) - 1);
	root.add(a[n - 1]);
	st[last = 1] = a[n - 1];

	int ans = -1;
	for (int i = n - 2; i >= 0; i--)
	{
		int best = root.get(29, a[i]);
		ans = max(ans, a[i] ^ best);
		while (last && st[last] < a[i]) root.remove(st[last--]);
		st[++last] = a[i];
		root.add(a[i]);
	}

	cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <cstdlib>
using namespace std;

int n, a[100100], r[100100];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);

	int ans = -1;
	r[n - 1] = n; a[n] = 1 << 30;

	for (int i = n - 2; i >= 0; i--)
	{
		r[i] = i + 1;
		while (r[i] < n && a[i] > a[r[i]])
		{
			ans = max(ans, a[i] ^ a[r[i]]);
			r[i] = r[r[i]];
		}
		if (r[i] < n) ans = max(ans, a[i] ^ a[r[i]]);
	}
	cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <cstdlib>
using namespace std;

int n, a[100100];

struct node
{
	node *l, *r;
	int low, high, mid;

	node()
	{
		l = NULL; r = NULL;
	}

	node(int _low, int _high)
	{
		l = NULL; r = NULL;
		low = _low; high = _high;
		mid = low / 2 + high / 2 + (low % 2 + high % 2) / 2;
	}

	void add(int val)
	{
		if (low == high) return;
		if (val <= mid)
		{
			if (l == NULL) l = new node(low, mid);
			l -> add(val);
		}
		else
		{
			if (r == NULL) r = new node(mid + 1, high);
			r -> add(val);
		}
	}

	int get(int bit, int val)
	{
		if (low == high) return low;
		int curBit = val >> bit & 1;
		if (curBit)
		{
			if (l != NULL) return l -> get(bit - 1, val);
			return r -> get(bit - 1, val);
		}
		if (r != NULL) return r -> get(bit - 1, val);
		return l -> get(bit - 1, val);
	}
};

int main()
{
	//freopen("b.in", "r", stdin);
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);

	node root(0, (1 << 30) - 1);
	root.add(a[n - 1]);
	int ans = -1, mx = a[n - 1];
	for (int i = n - 2; i >= 0; i--)
	{
		int best = root.get(30, a[i]);
		ans = max(ans, a[i] ^ best);
		if (a[i] > mx) mx = a[i], root.add(a[i]);
	}

	cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <cstdlib>
using namespace std;

int n, a[100100];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);

	int r = n - 1, ans = -1, mx = -1;

	for (int i = n - 2; i >= 0; i--)
	{
		if (a[i] < a[i + 1])
		{
			ans = max(ans, a[i] ^ a[i + 1]);
			mx = a[i];
		}
		else
		{
			while (r < n && a[r] < a[i])
			{
				mx = max(mx, a[r++]);
				ans = max(ans, a[i] ^ mx);
			}
			if (r < n) ans = max(ans, a[i] ^ a[r]);
		}
	}
	cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <cstdlib>
using namespace std;

int n, a[100100], st[100100], last;

struct node
{
	node *l, *r;
	int low, high, mid;

	node()
	{
		l = NULL; r = NULL;
	}

	node(int _low, int _high)
	{
		l = NULL; r = NULL;
		low = _low; high = _high;
		mid = low / 2 + high / 2 + (low % 2 + high % 2) / 2;
	}

	void add(int val)
	{
		if (low == high) return;
		if (val <= mid)
		{
			if (l == NULL) l = new node(low, mid);
			l -> add(val);
		}
		else
		{
			if (r == NULL) r = new node(mid + 1, high);
			r -> add(val);
		}
	}

	int remove(int val)
	{
		if (low == high) return 1;
		if (val <= mid)
		{
			if (l -> remove(val)) delete l, l = NULL;
		}
		else
		{
			if (r -> remove(val)) delete r, r = NULL;
		}
		return l == NULL && r == NULL;
	}

	int get(int bit, int val)
	{
		if (low == high) return low;
		int curBit = val >> bit & 1;
		if (curBit)
		{
			if (l != NULL) return l -> get(bit - 1, val);
			return r -> get(bit - 1, val);
		}
		if (r != NULL) return r -> get(bit - 1, val);
		return l -> get(bit - 1, val);
	}
};

int main()
{
	//freopen("b.in", "r", stdin);
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);

	node root(0, (1 << 30) - 1);
	root.add(a[n - 1]);
	st[last = 1] = a[n - 1];

	int ans = -1;
	for (int i = n - 2; i >= 0; i--)
	{
		int best = root.get(29, a[i]);
		if (last < 2 || st[2] < a[i]) ans = max(ans, a[i] ^ best);
		while (last && st[last] < a[i]) root.remove(st[last--]);
		st[++last] = a[i];
		root.add(a[i]);
	}

	cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <cstdlib>
using namespace std;

int n, a[100100];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);

	int r = n - 1, ans = -1, mx = -1;

	for (int i = n - 2; i >= 0; i--)
	{
		if (a[i] < a[i + 1])
		{
			ans = max(ans, a[i] ^ a[i + 1]);
			mx = a[i];
		}
		else
		{
			while (r < n && a[r] < a[i])
			{
				mx = max(mx, a[r++]);
				ans = max(ans, a[i] ^ mx);
			}
			mx = max(mx, a[i]);
			if (r < n) ans = max(ans, a[i] ^ a[r]);
		}
	}
	cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <cstdlib>
using namespace std;

int n, a[100100];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	int mx = max(a[n - 2], a[n - 1]), mx2 = min(a[n - 2], a[n - 1]);
	int ans = a[n - 2] ^ a[n - 1];
	for (int i = n - 3; i >= 0; i--)
		if (a[i] > mx2)
		{
			ans = max(ans, a[i] ^ mx);
			mx2 = a[i];
			if (mx2 > mx) swap(mx, mx2);
		}
	cout << ans << endl;
}


#include<iostream>
#include<cstdio>
using namespace std;

long long fuckstack[100002],node=0;
long long ans=0;
int main(){
    long long i,j,k,m,n,t,num;
    scanf("%I64d",&n);
    for(i=1;i<=n;i++){
        scanf("%I64d",&num);
        if(node==0)fuckstack[++node]=num;
        else {
            while(node!=0&&fuckstack[node]<=num){
                ans=max(ans,num^fuckstack[node]);
                node--;
            }
            ans=max(ans,num^fuckstack[node]);
            fuckstack[++node]=num;
        }
    }
    cout<<ans<<endl;
    //system("pause");
}


#include<iostream>
#include<cstdio>
using namespace std;

long long fuckstack[100002],node=0;
long long ans=0;
int main(){
    long long i,j,k,m,n,t,num;
    scanf("%I64d",&n);
    fuckstack[0]=0;
    for(i=1;i<=n;i++){
        scanf("%I64d",&num);
        if(node==0)fuckstack[++node]=num;
        else {
            while(node!=0&&fuckstack[node]<=num){
                ans=max(ans,num^fuckstack[node]);
                node--;
            }
            ans=max(ans,num^fuckstack[node]);
            fuckstack[++node]=num;
        }
    }
    cout<<ans<<endl;
    //system("pause");
}


#include<iostream>
#include<cstdio>
using namespace std;

long long fuckstack[100002],node=0;
long long ans=0;
int main(){
    long long i,j,k,m,n,t,num;
    scanf("%I64d",&n);
    fuckstack[0]=0;
    for(i=1;i<=n;i++){
        scanf("%I64d",&num);
        if(node==0)fuckstack[++node]=num;
        else {
            while(node!=0&&fuckstack[node]<=num){
                ans=max(ans,(num^fuckstack[node]));
                node--;
            }
            ans=max(ans,(num^fuckstack[node]));
            fuckstack[++node]=num;
        }
    }
    cout<<ans<<endl;
    //system("pause");
}


#include<iostream>
#include<cstdio>
using namespace std;

long long fuckstack[100002],node=0;
long long ans=0;
int main(){
    long long i,j,k,m,n,t,num;
    scanf("%I64d",&n);
    for(i=1;i<=n;i++){
        scanf("%I64d",&num);
        if(node==0)fuckstack[++node]=num;
        else {
            while(node!=0&&fuckstack[node]<=num){
                ans=max(ans,num^fuckstack[node]);
                node--;
            }
            if(node!=0)
            ans=max(ans,num^fuckstack[node]);
            fuckstack[++node]=num;
        }
    }
    cout<<ans<<endl;
    //system("pause");
}


#include<iostream>
#include<cstdio>
using namespace std;

long long fuckstack[100002],node=0;
long long ans=0;
int main(){
    long long i,j,k,m,n,t,num;
    scanf("%I64d",&n);
    for(i=1;i<=n;i++){
        scanf("%I64d",&num);
        if(node==0)fuckstack[++node]=num;
        else {
            while(node!=0&&fuckstack[node]<num){
                ans=max(ans,num^fuckstack[node]);
                node--;
            }
            ans=max(ans,num^fuckstack[node]);
            fuckstack[++node]=num;
        }
    }
    cout<<ans<<endl;
    //system("pause");
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1ull << (n))
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define revrep(i, n) for (int i = (n); i >= 0; --i)
#define pb push_back

template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }

template <class T> void uniq(T& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }

template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }

template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fix_pre(int n) { cout.setf(ios::fixed, ios::floatfield); cout.precision(10); }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

// y(v): v>^<  y(^): ^>v<
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

const double PI = acos(-1.0);

int n, s[ten(5)];
int gao()
{
    int res = 0;
    stack<int> sta;
    rep(i, n)
    {
        while (!sta.empty() && sta.top() < s[i])
        {
            chmax(res, sta.top() ^ s[i]);
            sta.pop();
        }
        sta.push(s[i]);
    }
    return res;
}
int main()
{
    cin >> n;
    input(s, n);

    int res = gao();
    reverse(s, s + n);
    chmax(res, gao());
    cout << res << endl;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1ull << (n))
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define revrep(i, n) for (int i = (n); i >= 0; --i)
#define pb push_back

template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }

template <class T> void uniq(T& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }

template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }

template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fix_pre(int n) { cout.setf(ios::fixed, ios::floatfield); cout.precision(10); }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

// y(v): v>^<  y(^): ^>v<
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

const double PI = acos(-1.0);

int n, s[ten(5)];
int gao()
{
    int res = 0;
    stack<int> sta;
    rep(i, n)
    {
        while (!sta.empty() && sta.top() < s[i])
        {
            chmax(res, sta.top() ^ s[i]);
            sta.pop();
        }
        sta.push(s[i]);
    }
    return res;
}
int main()
{
    fast_io();
    cin >> n;
    input(s, n);

    int res = gao();
    reverse(s, s + n);
    chmax(res, gao());
    cout << res << endl;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1ull << (n))
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define revrep(i, n) for (int i = (n); i >= 0; --i)
#define pb push_back

template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }

template <class T> void uniq(T& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }

template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }

template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fix_pre(int n) { cout.setf(ios::fixed, ios::floatfield); cout.precision(10); }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

// y(v): v>^<  y(^): ^>v<
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

const double PI = acos(-1.0);

#define F first
#define S second

int solve(const vector<int>& s)
{
    const int n = s.size();

    int res = 0;

    deque<int> q;
    q.pb(0);
    for (int i = 1; i < n; ++i)
    {
        while (!q.empty() && s[q.back()] < s[i])
        {
            chmax(res, s[q.back()] ^ s[i]);
            q.pop_back();
        }

        for (int j = (int)q.size() - 1; j >= 0 && s[q[j]] < s[i]; --j)
            chmax(res, s[q[j]] ^ s[i]);

        q.pb(i);
    }
    return res;
}
int main()
{
    fast_io();

    int n;
    while (cin >> n)
    {
        vector<int> s(n);
        input(s, n);

        int res = solve(s);
        reverse(all(s));
        chmax(res, solve(s));
        cout << res << endl;
    }
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1ull << (n))
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define revrep(i, n) for (int i = (n); i >= 0; --i)
#define pb push_back

template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }

template <class T> void uniq(T& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }

template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }

template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fix_pre(int n) { cout.setf(ios::fixed, ios::floatfield); cout.precision(10); }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

// y(v): v>^<  y(^): ^>v<
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

const double PI = acos(-1.0);

#define F first
#define S second

int solve(const vector<int>& s)
{
    const int n = s.size();

    int res = 0;
    set<int> poped;
    priority_queue<int> q;
    q.push(s[0]);
    for (int i = 0, j = 1; j < n; ++j)
    {
        q.push(s[j]);

        int max_s = q.top();
        q.pop();
        while (i < j && s[i] < s[j])
        {
            while (poped.count(q.top()))
                q.pop();

            if (!q.empty())
                chmax(res, max_s ^ q.top());

            poped.insert(s[i]);
            ++i;
        }
        q.push(max_s);
    }
    return res;
}
int main()
{
    fast_io();

    int n;
    while (cin >> n)
    {
        vector<int> s(n);
        input(s, n);

        int res = solve(s);
        reverse(all(s));
        chmax(res, solve(s));
        cout << res << endl;
    }
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define DEP 50

using namespace std;
typedef long long int ll;

struct bit
{
    bool end;
    bit *l,*r;
    bit(bool end=false,bit *l=NULL,bit *r=NULL):end(end),l(l),r(r){}
};
bit start;

void insert(ll a)
{
    bit *at=&start;
    for(ll i=DEP;i>=0;i--)
    {
        if(1LL<<i>a||!(a>>i&1))
        {
            if(at->l==NULL) at->l=new bit();
            at=at->l;
        }
        else
        {
            if(at->r==NULL) at->r=new bit();
            at=at->r;
        }
    }at->end=true;
}
ll near(ll a)
{
    bit *at=&start;
    ll xr=0;
    ll sm=0;
    for(int i=DEP;i>=0;i--)
    {
        if((1LL<<i>a||!(a>>i&1))&&at->r!=NULL)
        {
            at=at->r;
            sm+=1LL<<i;
            if(at->end) xr=sm;
        }
        else if(at->l!=NULL)
        {
            at=at->l;
            if(at->end) xr=sm;
        }
        else break;
    }
    return a^xr;
}
ll rui=0;

int main()
{
    int n;
    scanf("%d",&n);
    ll ret=0;
    insert(0);
    for(int i=0;i<n;i++)
    {
        ll a;
        scanf("%I64d",&a);
        rui^=a;
        insert(a);
        ret=max(ret,near(rui));
    }
    printf("%I64d\n",ret);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <stack>

using namespace std;

int in[100005];
stack <int> st;

int main()
{
	int n;
	scanf("%d",&n);
	int ret=0;
	for(int i=0;i<n;i++) scanf("%d",&in[i]);
	for(int i=n-1;i>=0;i--)
	{
		while(!st.empty()&&st.top()<in[i])
		{
			ret=max(ret,st.top()^in[i]);
			st.pop();
		}
		st.push(in[i]);
	}
	printf("%d\n",ret);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

vector <int> in;

int solve(int n)
{
	int ret=0;
	stack <int> st;
	for(int i=0;i<n;i++)
	{
		while(!st.empty()&&st.top()<in[i])
		{
			ret=max(ret,st.top()^in[i]);
			st.pop();
		}st.push(in[i]);
	}return ret;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		in.push_back(a);
	}
	int ret=solve(n);
	reverse(in.begin(),in.end());
	printf("%d\n",max(solve(n),ret));
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define DEP 50

using namespace std;
typedef long long int ll;

struct bit
{
    bool end;
    bit *l,*r;
    bit(bool end=false,bit *l=NULL,bit *r=NULL):end(end),l(l),r(r){}
};
bit start;

void insert(ll a)
{
    bit *at=&start;
    for(ll i=DEP;i>=0;i--)
    {
        if(1LL<<i>a||!(a>>i&1))
        {
            if(at->l==NULL) at->l=new bit();
            at=at->l;
        }
        else
        {
            if(at->r==NULL) at->r=new bit();
            at=at->r;
        }
    }at->end=true;
}
ll near(ll a)
{
    bit *at=&start;
    ll xr=0;
    ll sm=0;
    for(int i=DEP;i>=0;i--)
    {
        if((1LL<<i>a||!(a>>i&1))&&at->r!=NULL)
        {
            at=at->r;
            sm+=1LL<<i;
            if(at->end) xr=sm;
        }
        else
        {
            at=at->l;
            if(at->end) xr=sm;
        }
    }
    return a^xr;
}
ll rui=0;

int main()
{
    int n;
    scanf("%d",&n);
    ll ret=0;
    insert(0);
    for(int i=0;i<n;i++)
    {
        ll a;
        scanf("%I64d",&a);
        rui^=a;
        insert(a);
        ret=max(ret,near(rui));
    }
    printf("%I64d\n",ret);
    return 0;
}


#include <cstdio>
#include <algorithm>

const int maxn = 100000 + 10 ;
int n,stk[maxn],data[maxn] ;
int main (){

    for( ; 1 == scanf ("%d", &n ); ){
        int ans = 0 ;
        for(int i=1;i<=n; ++i)
            scanf ("%d" ,data + i ) ;
        int top = 0 ;
        for(int i=1; i <= n ; ++i){
            int now = data[i], pre = data[ i ] ;
            while ( top && data[stk[top-1]] <= now){
                ans = std::max (ans , now^data[stk[top-1]] ) ;
                ans = std::max (ans , pre^data[stk[top-1]] ) ;
                --top;
                pre = data[stk[top] ] ;
            }
            stk[top++]=i;
        }
       // printf ("%d\n", top );
        while(top>=2) {
            ans  = std::max( ans , data[stk[top-1]]^data[stk[top-2]] ) ;
            --top ;
        }
        printf ("%d\n",ans) ;
    }
    return 0;
}


#include <cstdio>
#include <algorithm>

const int maxn = 100000 + 10 ;
int n,stk[maxn],data[maxn] ;
int main (){
    int ans = 0 ;
    for( ; 1 == scanf ("%d", &n ); ){
        for(int i=1;i<=n; ++i)
            scanf ("%d" ,data + i ) ;
        int top = 0 ;
        for(int i=1; i <= n ; ++i){
            int now = data[i], pre = data[ i ] ;
            while ( top && data[stk[top-1]] <= now){
                ans = std::max (ans , now^data[stk[top-1]] ) ;
                ans = std::max (ans , pre^data[stk[top-1]] ) ;
                --top;
                pre = data[stk[top] ] ;
            }
            stk[top++]=i;
        }
       // printf ("%d\n", top );
        while(top>=2) {
            ans  = std::max( ans , data[stk[top-1]]^data[stk[top-2]] ) ;
            --top ;
        }
        printf ("%d\n",ans) ;
    }
    return 0;
}


#include <cstdio>
#include <algorithm>

const int maxn = 100000 + 10 ;
int n,stk[maxn],data[maxn],ans ;
void gao() ;
int main (){

    for( ; 1 == scanf ("%d", &n ); ){
        ans = 0 ;
        for(int i=1;i<=n; ++i)
            scanf ("%d" ,data + i ) ;
        gao() ;
        std::reverse( data+ 1 , data + 1 + n ) ;
        gao() ;
        printf ("%d\n",ans) ;
    }
    return 0;
}

void gao(){
        int top = 0 ;
        for(int i=1; i <= n ; ++i){
            int now = data[i], pre = data[ i ] ;
            while ( top && data[stk[top-1]] <= now){
                ans = std::max (ans , now^data[stk[top-1]] ) ;
                ans = std::max (ans , pre^data[stk[top-1]] ) ;
                --top;
                pre = data[stk[top] ] ;
            }
            stk[top++]=i;
        }
       // printf ("%d\n", top );
        while(top>=2) {
            ans  = std::max( ans , data[stk[top-1]]^data[stk[top-2]] ) ;
            --top ;
        }

}


#include <cstdio>
#include <algorithm>

const int maxn = 100000 + 10 ;
int n,stk[maxn],data[maxn],ans ;
void gao() ;
int main (){

    for( ; 1 == scanf ("%d", &n ); ){
        ans = 0 ;
        for(int i=1;i<=n; ++i)
            scanf ("%d" ,data + i ) ;
        gao() ;
        std::reverse( data+ 1 , data + 1 + n ) ;
//        gao() ;
        printf ("%d\n",ans) ;
    }
    return 0;
}

void gao(){
        int top = 0 ;
        for(int i=1; i <= n ; ++i){
            int now = data[i], pre = data[ i ] ;
            while ( top && data[stk[top-1]] <= now){
                ans = std::max (ans , now^data[stk[top-1]] ) ;
                ans = std::max (ans , pre^data[stk[top-1]] ) ;
                --top;
                pre = data[stk[top] ] ;
            }
            if(top>=1) ans = std::max( ans ,data[stk[top-1]]^now );
            stk[top++]=i;
        }
       // printf ("%d\n", top );
        while(top>=2) {
            ans  = std::max( ans , data[stk[top-1]]^data[stk[top-2]] ) ;
            --top ;
        }

}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
const int N = 100010;
const int inf=1000000001;
int a[N];
map<int,int> mp;
int p1[N],p2[N];
int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        mp[a[i]]=i;
    }
    set<int> st;
    st.insert(inf);
    int ans=0;
    for(int i=1;i<=n;i++){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            ans=max(ans,a[i]^(*iter));
            p1[i]=mp[*iter];
            st.insert(a[i]);
        }
    }
    st.clear();
    st.insert(inf);
    for(int i=n;i>=1;i--){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            int v=mp[*iter];
            int u=p1[v];
            if(p2[v]==0){
                p2[v]=i;
                if(u<i){
                    ans=max(ans,a[v]^a[i]);
                }
            }else if(a[p2[v]]<a[i]){
                p2[v]=i;
                if(u<i){
                    ans=max(ans,a[v]^a[i]);
                }
            }
            st.insert(a[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
const int N = 100010;
const int inf=1000000001;
int a[N];
int v[N];
int main(void)
{
    int n,ans=0;
    //~ for(int i=0;i<10;i++){
        //~ printf("%d\n",a[i]^134189790);
    //~ }
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    v[0]=inf;
    int rear=0;
    for(int i=1;i<=n;i++){
        while(rear>0&&v[rear]<a[i]){
            rear--;
        }

        if(v[rear]!=inf){
            ans=max(ans,a[i]^v[rear]);
        }
        v[++rear]=a[i];
    }
    reverse(a+1,a+1+n);
    rear=0;
    for(int i=1;i<=n;i++){
        while(rear>0&&v[rear]<a[i]){
            rear--;
        }
        if(v[rear]!=inf){
            ans=max(ans,a[i]^v[rear]);
        }
        v[++rear]=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
const int N = 100010;
const int inf=1000000001;
int a[N];
int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    set<int> st;
    st.insert(inf);
    int ans=0;
    for(int i=1;i<=n;i++){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            ans=max(ans,(*iter)^a[i]);
            st.insert(a[i]);
        }
    }
    st.clear();
    st.insert(inf);
    for(int i=n;i>=1;i--){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            ans=max(ans,(*iter)^a[i]);
            st.insert(a[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
const int N = 100010;
const int inf=1000000001;
int a[N];
map<int,int> mp;
int p1[N],p2[N];
int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        mp[a[i]]=i;
    }
    set<int> st;
    st.insert(inf);
    int ans=0;
    for(int i=1;i<=n;i++){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            p1[i]=mp[*iter];
            st.insert(a[i]);
        }
    }
    st.clear();
    st.insert(inf);
    for(int i=n;i>=1;i--){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            if(p2[mp[*iter]]!=0){
                p2[mp[*iter]]=i;
            }
            st.insert(a[i]);
        }
    }
    for(int i=2;i<=n;i++){
        if(p1[i]==0){
            ans=max(ans,a[i]^a[p2[i]]);
        }else if(p2[i]==0){
            ans=max(ans,a[i]^a[p1[i]]);
        }else if(p1[i]<p2[i]){
            ans=max(ans,max(a[i]^a[p1[i]],a[i]^a[p2[i]]));
        }else{
            ans=max(ans,a[i]^a[p1[i]]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
const int N = 100010;
const int inf=1000000001;
int a[N];
map<int,int> mp;
int p1[N],p2[N];
int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        mp[a[i]]=i;
    }
    set<int> st;
    st.insert(inf);
    int ans=0;
    for(int i=1;i<=n;i++){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            p1[i]=mp[*iter];
            st.insert(a[i]);
        }
    }
    st.clear();
    st.insert(inf);
    for(int i=n;i>=1;i--){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            p2[mp[*iter]]=i;
            st.insert(a[i]);
        }
    }
    for(int i=2;i<=n;i++){
        if(p1[i]==0){
            ans=max(ans,a[i]^a[p2[i]]);
        }else if(p2[i]==0){
            ans=max(ans,a[i]^a[p1[i]]);
        }else if(p1[i]<p2[i]){
            ans=max(ans,max(a[i]^a[p1[i]],a[i]^a[p2[i]]));
        }else{
            ans=max(ans,a[i]^a[p1[i]]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
const int N = 100010;
const int inf=1000000001;
int a[N];
map<int,int> mp;
int p1[N],p2[N];
int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        mp[a[i]]=i;
    }
    set<int> st;
    st.insert(inf);
    int ans=0;
    for(int i=1;i<=n;i++){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            ans=max(ans,a[i]^(*iter));
            p1[i]=mp[*iter];
            st.insert(a[i]);
        }
    }
    st.clear();
    st.insert(inf);
    for(int i=n;i>=1;i--){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            int v=mp[*iter];
            int u=p1[v];
            p2[v]=i;
            if(u<i){
                ans=max(ans,a[v]^a[i]);
            }
            st.insert(a[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
const int N = 100010;
const int inf=1000000001;
int a[N];
int v[N];
int main(void)
{
    int n,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    v[0]=inf;
    int rear=0;
    for(int i=1;i<=n;i++){
        while(rear>0&&v[rear]<a[i]){
            rear--;
        }
        if(v[rear]!=inf){
            ans=max(ans,a[i]^v[rear]);
        }
        v[++rear]=a[i];
    }
    reverse(v+1,v+1+n);
    rear=0;
    for(int i=1;i<=n;i++){
        while(rear>0&&v[rear]<a[i]){
            rear--;
        }
        if(v[rear]!=inf){
            ans=max(ans,a[i]^v[rear]);
        }
        v[++rear]=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
const int N = 100010;
const int inf=1000000001;
int a[N];
map<int,int> mp;
int p1[N],p2[N];
int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        mp[a[i]]=i;
    }
    set<int> st;
    st.insert(inf);
    int ans=0;
    for(int i=1;i<=n;i++){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            p1[i]=mp[*iter];
            st.insert(a[i]);
        }
    }
    st.clear();
    st.insert(inf);
    for(int i=n;i>=1;i--){
        set<int>::iterator iter;
        iter=st.upper_bound(a[i]);
        if(*iter==inf){
            st.insert(a[i]);
        }
        else{
            if(p2[mp[*iter]]!=0){
                p2[mp[*iter]]=i;
            }else if(a[p2[mp[*iter]]]<a[i]){
                p2[mp[*iter]]=i;
            }
            st.insert(a[i]);
        }
    }
    for(int i=2;i<=n;i++){
        if(p1[i]==0){
            ans=max(ans,a[i]^a[p2[i]]);
        }else if(p2[i]==0){
            ans=max(ans,a[i]^a[p1[i]]);
        }else if(p1[i]<p2[i]){
            ans=max(ans,max(a[i]^a[p1[i]],a[i]^a[p2[i]]));
        }else{
            ans=max(ans,a[i]^a[p1[i]]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

const int MAXN = 100 * 100 * 100;
int n, a[MAXN], l[MAXN], r[MAXN], ans;
stack <int> q, u;

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

        for (int i = 0; i < n; i++) {
        	while (!q.empty() && q.top() < a[i])
        		q.pop();

             	if (i && !q.empty())
                	l[i] = q.top();
             	q.push(a[i]);
             	if (!l[i])
             		l[i] = a[0];

        }

        for (int i = n - 1; i >= 0; i--) {
                while (!u.empty() && u.top() < a[i])
        		u.pop();

             	if (i < n - 1 && !u.empty())
                	r[i] = u.top();

             	u.push(a[i]);

             	if (!r[i])
             		r[i] = a[n - 1];

        }

        for (int i = 0; i < n; i++) {
        	ans = max((a[i] ^ l[i]), (a[i] ^ r[i]));

        }
        cout << ans;

return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

const int MAXN = 100 * 100 * 100;
int n, a[MAXN], l[MAXN], r[MAXN], ans;
stack <int> q, u;

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

        for (int i = 0; i < n; i++) {
        	while (!q.empty() && q.top() < a[i])
        		q.pop();

             	if (i && !q.empty())
                	l[i] = q.top();
             	q.push(a[i]);
        //     	if (!l[i])
          //   		l[i] = a[0];

        }

        for (int i = n - 1; i >= 0; i--) {
                while (!u.empty() && u.top() < a[i])
        		u.pop();

             	if (i < n - 1 && !u.empty())
                	r[i] = u.top();

             	u.push(a[i]);

             //	if (!r[i])
            // 		r[i] = a[n - 1];

        }

        for (int i = 0; i < n; i++) {
        	ans = max((a[i] ^ l[i]), (a[i] ^ r[i]));

        }
        cout << ans;

return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

const int MAXN = 100 * 100 * 100;
int n, a[MAXN], l[MAXN], r[MAXN], ans;
stack <int> q, u;

int main() {
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

        for (int i = 0; i < n; i++) {
        	while (!q.empty() && q.top() < a[i])
        		q.pop();

             	if (i && !q.empty())
                	l[i] = q.top();
             	q.push(a[i]);

        }

        for (int i = n - 1; i >= 0; i--) {
                while (!u.empty() && u.top() < a[i])
        		u.pop();

             	if (i < n - 1 && !u.empty())
                	r[i] = u.top();

             	u.push(a[i]);

        }

        for (int i = 0; i < n; i++) {
        	if (!l[i] && r[i]) {
        		ans = max(ans, (a[i] ^ r[i]));
              	} else if (!r[i] && l[i]) {
              		ans = max(ans, (a[i] ^ l[i]));
        	} else if (l[i] && r[i]) {
        		ans = max(ans, max((a[i] ^ l[i]), (a[i] ^ r[i])));
    		}
    	}

        cout << ans;

return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

const int MAXN = 100 * 100 * 100;
int n, a[MAXN], l[MAXN], r[MAXN], ans;
stack <int> q, u;

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

        for (int i = 0; i < n; i++) {
        	while (!q.empty() && q.top() < a[i])
        		q.pop();

             	if (i && !q.empty())
                	l[i] = q.top();
             	q.push(a[i]);
        //     	if (!l[i])
          //   		l[i] = a[0];

        }

        for (int i = n - 1; i >= 0; i--) {
                while (!u.empty() && u.top() < a[i])
        		u.pop();

             	if (i < n - 1 && !u.empty())
                	r[i] = u.top();

             	u.push(a[i]);

             //	if (!r[i])
            // 		r[i] = a[n - 1];

        }

        for (int i = 0; i < n; i++) {

        	ans = max(ans, max((a[i] ^ l[i]), (a[i] ^ r[i])));

        }

        cout << ans;

return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[100005],ls[100005],t[200005];
int lowbit(int x){return x & (-x);}
void insert1(int now,int val)
{
	while(now)
	{
		t[now] = max(t[now],val);
		now -= lowbit(now);
	}
}
void insert2(int now,int val)
{
	while(now)
	{
		t[now] = min(t[now],val);
		now -= lowbit(now);
	}
}
int ask1(int now)
{
	int re = 0;
	while(now <= n)
	{
		re = max(re,t[now]);
		now += lowbit(now);
	}
	return re;
}
int ask2(int now)
{
	int re = n + 1;
	while(now <= n)
	{
		re = min(re,t[now]);
		now += lowbit(now);
	}
	return re;
}
int main()
{
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
		scanf("%d",&a[i]),ls[i] = a[i];
	if(n == 1) {printf("%d\n",0); return 0;}
	sort(ls + 1, ls + n + 1);
	ls[0] = unique(ls + 1, ls + n + 1) - ls - 1;
	for (int i = 1; i <= n; i++)
		a[i] = lower_bound(ls + 1, ls + ls[0] + 1,a[i]) - ls;
	int ans = 0;
	insert1(a[1],1);
	for (int i = 2; i <= n; i++)
	{
		if(ask1(a[i] + 1) > 0)ans = max(ans,ls[a[i]]^ls[a[ask1(a[i] + 1)]]);
		insert1(a[i],i);
	}
	for (int i = 1; i <= n; i++)
		t[i] = n + 1;
	insert2(a[n],n);
	for (int i = n - 1; i >= 1; i--)
	{
		if(ask2(a[i] + 1) < n + 1)ans = max(ans,ls[a[i]]^ls[a[ask2(a[i] + 1)]]);
		insert2(a[i],i);
	}
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define lc (x << 1)
#define rc ((lc) + 1)
using namespace std;
const int MAXN = 111111;
int T[MAXN * 4], a[MAXN], n;
void build(int x, int l, int r) {
    if (l == r) T[x] = a[l];
    else {
        int mid = (l + r) >> 1;
        build(lc, l, mid);
        build(rc, mid +1 , r);
        T[x] = max(T[lc], T[rc]);
    }
}

int query(int x, int l, int r, int ll, int rr) {
    if (ll <= l && rr >= r) {
        return T[x];
    }
    else {
        int mid = (l + r) >> 1;
        int ret = 0;
        if (ll <= mid) ret = max(ret, query(lc, l, mid, ll, rr));
        if (rr > mid) ret = max(ret, query(rc, mid + 1, r, ll, rr));
        return ret;
    }
}
int getnum(int pos, int x) {
    int l = pos, r = n;
    while (l < r) {
        int mid = (l + r) >> 1;
        if (query(1, 1, n, pos, mid) >= x) {
            r = mid;
        }
        else l = mid + 1;
    }
    while  (query(1, 1, n, pos, l) < x && l <= n) l++;
    if (l > n) return -1;
    return a[l];
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

    build(1, 1, n);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int t = getnum(i + 1, a[i] + 1);
        if (t < 0) continue;
        ans = max(a[i] ^ t, ans);
    }
    reverse(a + 1, a + n + 1);

    build(1, 1, n);

    for (int i = 1; i <= n; i++) {
        int t = getnum(i + 1, a[i] + 1);
        if (t < 0) continue;
        ans = max(a[i] ^ t, ans);
    }

    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[100005],ls[100005],t[200005];
int lowbit(int x){return x & (-x);}
void insert1(int now,int val)
{
    while(now)
    {
        t[now] = max(t[now],val);
        now -= lowbit(now);
    }
}
void insert2(int now,int val)
{
    while(now)
    {
        t[now] = min(t[now],val);
        now -= lowbit(now);
    }
}
int ask1(int now)
{
    int re = 0;
    while(now <= n)
    {
        re = max(re,t[now]);
        now += lowbit(now);
    }
    return re;
}
int ask2(int now)
{
    int re = n + 1;
    while(now <= n)
    {
        re = min(re,t[now]);
        now += lowbit(now);
    }
    return re;
}
int main()
{
    scanf("%d",&n);
    if(n == 1) {printf("0\n"); return 0;}
    for (int i = 1; i <= n; i++)
        scanf("%d",&a[i]),ls[i] = a[i];
    sort(ls + 1, ls + n + 1);
    ls[0] = unique(ls + 1, ls + n + 1) - ls - 1;
    for (int i = 1; i <= n; i++)
        a[i] = lower_bound(ls + 1, ls + ls[0] + 1,a[i]) - ls;
    int ans = 0;
    insert1(a[1],1);
    for (int i = 2; i <= n; i++)
    {
        if(ask1(a[i] + 1) > 0)ans = max(ans,ls[a[i]]|ls[a[ask1(a[i] + 1)]]);
        insert1(a[i],i);
    }
    for (int i = 1; i <= 2 * n; i++)
        t[i] = n + 1;
    insert2(a[n],n);
    for (int i = n - 1; i >= 1; i--)
    {
        if(ask2(a[i] + 1) < n + 1)ans = max(ans,ls[a[i]]|ls[a[ask2(a[i] + 1)]]);
        insert2(a[i],i);
    }
    printf("%d\n",ans);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[100005],ls[100005],t[200005];
int lowbit(int x){return x & (-x);}
void insert1(int now,int val)
{
    while(now)
    {
        t[now] = max(t[now],val);
        now -= lowbit(now);
    }
}
void insert2(int now,int val)
{
    while(now)
    {
        t[now] = min(t[now],val);
        now -= lowbit(now);
    }
}
int ask1(int now)
{
    int re = 0;
    while(now <= n)
    {
        re = max(re,t[now]);
        now += lowbit(now);
    }
    return re;
}
int ask2(int now)
{
    int re = n + 1;
    while(now <= n)
    {
        re = min(re,t[now]);
        now += lowbit(now);
    }
    return re;
}
int main()
{
    scanf("%d",&n);
    if(n == 1) printf("0\n");
    for (int i = 1; i <= n; i++)
        scanf("%d",&a[i]),ls[i] = a[i];
    sort(ls + 1, ls + n + 1);
    ls[0] = unique(ls + 1, ls + n + 1) - ls - 1;
    for (int i = 1; i <= n; i++)
        a[i] = lower_bound(ls + 1, ls + ls[0] + 1,a[i]) - ls;
    int ans = 0;
    //for (int i = 1; i <= n; i++)
    //  printf("%d ",a[i]);
    insert1(a[1],1);
    for (int i = 2; i <= n; i++)
    {
        if(ask1(a[i] + 1) > 0)ans = max(ans,ls[a[i]]|ls[a[ask1(a[i] + 1)]]);
        //printf("ok1 = %d %d\n",i,ask1(a[i] + 1));
        insert1(a[i],i);
    }
    for (int i = 1; i <= 2 * n; i++)
        t[i] = n + 1;
    insert2(a[n],n);
    for (int i = n - 1; i >= 1; i--)
    {
        if(ask2(a[i] + 1) < n + 1)ans = max(ans,ls[a[i]]|ls[a[ask2(a[i] + 1)]]);
        //printf("ok2 = %d %d\n",i,ask2(a[i] + 1));
        insert2(a[i],i);
    }
    printf("%d\n",ans);
    return 0;
}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    cin >> n;
    vector <int> s(n), e;
    int maxx=0, minn= (1 << 30);
    for (int i=0; i<n; i++)
    {
        cin >> s[i];
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }

    while (1 << (st2+1) <= maxx)
    {
        st2++;
    }
    while ((1 << st2 ) <= minn)
    {
        vychet+=(1 << st2 );
        minn-=(1 << st2);
        maxx-=(1 << st2);
        st2=0;
        while (1 << (st2+1) <= maxx)
        {
            st2++;
        }
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i] >> st2);
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    scanf("%d", &n);
    vector <int> s(n), e;
    int maxx=0, minn=pow(2, 30);
    for (int i=0; i<n; i++)
    {
        scanf("%d", &s[i]);
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }

    while (1 << (st2+1) <= maxx)
    {
        st2++;
    }
    while ((1 << st2 ) <= minn)
    {
        vychet+=(1 << st2 );
        minn-=(1 << st2);
        maxx-=(1 << st2);
        st2=0;
        while (1 << (st2+1) <= maxx)
        {
            st2++;
        }
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i] >> st2);
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    scanf("%d", &n);
    vector <int> s(n), e;
    int maxx=0, minn=pow(2, 30);
    for (int i=0; i<n; i++)
    {
        scanf("%d", &s[i]);
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }

    while (1 << (st2+1) <= maxx)
    {
        st2++;
    }
    while ((1 << st2 ) <= minn)
    {
        vychet+=(1 << st2 );
        --st2;
        minn-=(1 << st2);
        maxx-=(1 << st2);
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i] >> st2);
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    scanf("%d", &n);
    vector <int> s(n), e;
    int maxx=0, minn=pow(2, 30);
    for (int i=0; i<n; i++)
    {
        scanf("%d", &s[i]);
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }

    while (1 << (st2+1) <= maxx)
    {
        st2++;
    }
    while ((1 << st2 ) <= minn)
    {
        vychet+=(1 << st2 );
        minn-=(1 << st2);
        maxx-=(1 << st2);
        while (1 << (st2+1) <= maxx)
        {
            st2++;
        }
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i] >> st2);
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    vector <int> s, e;
    cin >> n;
    int cinn, maxx=0, minn=pow(2, 30);
    for (int i=0; i<n; i++)
    {
        cin >> cinn;
        s.push_back(cinn);
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }
    while (pow(2, (st2+1)) <= maxx)
    {
        st2++;
    }
    while (pow(2, st2 ) <= minn)
    {
        vychet+=st2;
        st2=st2/2;
        minn-=st2;
        maxx-=st2;
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i]/pow(2, st2));
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    scanf("%d", &n);
    vector <int> s(n), e;
    int maxx=0, minn=pow(2, 30);
    for (int i=0; i<n; i++)
    {
        scanf("%d", &s[i]);
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }

    while (1 << (st2+1) <= maxx)
    {
        st2++;
    }
    while ((1 << st2 ) <= minn)
    {
        vychet+=(1 << st2 );
        minn-=(1 << st2);
        maxx-=(1 << st2);
        --st2;
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i] >> st2);
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    cin >> n;
    vector <int> s(n), e;
    int maxx=0, minn= (1 << 30);
    for (int i=0; i<n; i++)
    {
        cin >> s[i];
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }

    while (1 << (st2+1) <= maxx)
    {
        st2++;
    }
    while ((1 << st2 ) <= minn)
    {
        vychet+=(1 << st2 );
        minn-=(1 << st2);
        maxx-=(1 << st2);
        st2=0;
        while (1 << (st2+1) <= maxx)
        {
            st2++;
        }
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i] >> st2);
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<=s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<=s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    vector <int> s, e;
    scanf("%d", &n);
    int cinn, maxx=0, minn=pow(2, 30);
    for (int i=0; i<n; i++)
    {
        scanf("%d", &cinn);
        s.push_back(cinn);
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }
    while (1 << (st2+1) <= maxx)
    {
        st2++;
    }
    while ((1 << st2 ) <= minn)
    {
        vychet+=st2;
        st2=st2/2;
        minn-=st2;
        maxx-=st2;
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i]/pow(2, st2));
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    vector <int> s, e;
    cin >> n;
    int cinn, maxx=0, minn=pow(2, 30);
    for (int i=0; i<n; i++)
    {
        cin >> cinn;
        s.push_back(cinn);
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }
    while (pow(2, (st2+1)) <= maxx)
    {
        st2++;
    }
    while (pow(2, st2 ) <= minn)
    {
        vychet+=st2;
        st2=st2/2;
        minn-=st2;
        maxx-=st2;
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i]/pow(2, st2));
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] | s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] | s[i]);
            }
        }
    }
    cout << otv;

}


#pragma comment(linker, "/STACK:256000000")
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

/*
class dual
{
public:
    int a, b;
    dual()
    {
        b=rand();
    }
}
;
int operator < (const dual& s, const dual& d)
{
    return ((s.a < d.a) || (s.a == d.a)  &&  (s.b < d.b) ) ;
}

int dfs(int y)
{
    b[y]=1;
    for (int i=0; i<210; i++)
    {
        if (a[y][i]==1 && b[i]==0)
        {
            dfs(i);
        }
    }
    return 0;
}
*/

int main()
{
    int n,  st2=0, vychet=0;
    scanf("%d", &n);
    vector <int> s(n), e;
    int maxx=0, minn=pow(2, 30);
    for (int i=0; i<n; i++)
    {
        scanf("%d", &s[i]);
        if (s[i]>maxx)
            maxx=s[i];
        if (s[i]<minn)
            minn=s[i];
    }

    while (1 << (st2+1) <= maxx)
    {
        st2++;
    }
    while ((1 << st2 ) <= minn)
    {
        vychet+=(1 << st2 );
        --st2;
        minn-=(1 << st2);
        maxx-=(1 << st2);
    }
    for (int i=0; i<n; i++)
    {
        s[i]-=vychet;
        e.push_back(s[i]/pow(2, st2));
    }
    int maxpr=0, poslmax=-1, otv=0;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    reverse(s.begin(), s.end());
    reverse(e.begin(), e.end());
    maxpr=0, poslmax=-1;
    for (int i=0; i<n; i++)
    {
        if (e[i]==1)
        {
            maxpr=0;
            poslmax=i;
        }
        else
        {
            if (poslmax!=-1 && maxpr<s[i])
            {
                maxpr=s[i];
                otv= max(otv, s[poslmax] ^ s[i]);
            }
        }
    }
    cout << otv;

}


#include <cstdlib>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
    vector<int> numbers;
    int n;
    cin>>n;
    for(int i=0; i<n; ++i){
        int a;
        cin>>a;
        numbers.push_back(a);
    }

    set<int> highest;
    for(int h = 25; h>=0; --h){
        bool found = false;
        bool notfound = false;
        highest.clear();
        for(int i =0; i<n; ++i){
            if( (numbers[i] & (1<<h)) > 0){
                found = true;
                highest.insert(i);
            }else{
                notfound = true;
            }
        }
        if(found && notfound){
             int lucky = 0;
            set<int>::iterator it;
            for(it = highest.begin(); it!= highest.end(); ++i){
                int curr = *it;
                for(int k = curr -1; k>=0; --k){
                    int sec = numbers[k];
                    if( (curr ^ sec ) > lucky ){
                        lucky = curr ^ sec;
                    }
                    if(highest.found(k) == set::end ){
                        break;
                    }
                }
                for(int k = curr + 1; k<n; ++k){
                    int sec = numbers[k];
                    if( (curr ^ sec ) > lucky ){
                        lucky = curr ^ sec;
                    }
                    if(highest.found(k) == set::end ){
                        break;
                    }
                }
            }

            cout<<lucky;
            return 0;
        }
    }
    return EXIT_SUCCESS;
}


#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
    vector<int> numbers;
    int n;
    cin>>n;
    for(int i=0; i<n; ++i){
        int a;
        cin>>a;
        numbers.push_back(a);
    }

    set<int> highest;
    for(int h = 25; h>=0; --h){
        bool found = false;
        bool notfound = false;
        highest.clear();
        for(int i =0; i<n; ++i){
            if( (numbers[i] & (1<<h)) > 0){
                found = true;
                highest.insert(i);
            }else{
                notfound = true;
            }
        }
        if(found && notfound){
             int lucky = 0;
            set<int>::iterator it;
            for(it = highest.begin(); it!= highest.end(); ++i){
                int curr = *it;
                for(int k = curr -1; k>=0; --k){
                    int sec = numbers[k];
                    if( (curr ^ sec ) > lucky ){
                        lucky = curr ^ sec;
                    }
                    if(highest.found(k) == set::end ){
                        break;
                    }
                }
                for(int k = curr + 1; k<n; ++k){
                    int sec = numbers[k];
                    if( (curr ^ sec ) > lucky ){
                        lucky = curr ^ sec;
                    }
                    if(highest.found(k) == set::end ){
                        break;
                    }
                }
            }

            cout<<lucky;
            return 0;
        }
    }
    return EXIT_SUCCESS;
}


#include <cstdlib>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
    vector<int> numbers;
    int n;
    cin>>n;
    for(int i=0; i<n; ++i){
        int a;
        cin>>a;
        numbers.push_back(a);
    }

    set<int> highest;
    for(int h = 30; h>=0; --h){
        bool found = false;
        bool notfound = false;
        highest.clear();
        for(int i =0; i<n; ++i){
            if( (numbers[i] & (1<<h)) > 0){
                found = true;
                highest.insert(i);
            }else{
                notfound = true;
            }
        }

        if(found && notfound){
             int lucky = -1;
            set<int>::iterator it;
            for(it = highest.begin(); it!= highest.end(); ++it){
                int curr = *it;
                int currn = numbers[curr];
                int max = 0;
                for(int k = curr -1; k>=0; --k){
                    if(highest.find(k) != highest.end() ){
                        break;
                    }
                    int sec = numbers[k];

                    if(sec < max){
                        continue;
                    }else{
                        max = sec;
                    }
                    if( (currn ^ sec ) > lucky ){
                        lucky = currn ^ sec;
                    }

                }
                max = 0;
                for(int k = curr + 1; k<n; ++k){
                    if(highest.find(k) != highest.end() ){
                        break;
                    }
                    int sec = numbers[k];
                    if(sec < max){
                        continue;
                    }else{
                        max = sec;
                    }
                    if( (currn ^ sec ) > lucky ){
                        lucky = currn ^ sec;
                    }
                }
            }
            cout<<lucky;
            return 0;
        }
    }
    return EXIT_SUCCESS;
}


#include <cstdlib>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
    vector<int> numbers;
    int n;
    cin>>n;
    for(int i=0; i<n; ++i){
        int a;
        cin>>a;
        numbers.push_back(a);
    }

    set<int> highest;
    for(int h = 25; h>=0; --h){
        bool found = false;
        bool notfound = false;
        highest.clear();
        for(int i =0; i<n; ++i){
            if( (numbers[i] & (1<<h)) > 0){
                found = true;
                highest.insert(i);
            }else{
                notfound = true;
            }
        }

        if(found && notfound){
             int lucky = -1;
            set<int>::iterator it;
            for(it = highest.begin(); it!= highest.end(); ++it){
                int curr = *it;
                int currn = numbers[curr];
                int max = 0;
                for(int k = curr -1; k>=0; --k){
                    int sec = numbers[k];
                    if(sec < max){
                        continue;
                    }else{
                        max = sec;
                    }
                    if( (currn ^ sec ) > lucky ){
                        lucky = currn ^ sec;
                    }
                    if(highest.find(k) != highest.end() ){
                        break;
                    }
                }
                max = 0;
                for(int k = curr + 1; k<n; ++k){
                    int sec = numbers[k];
                    if(sec < max){
                        continue;
                    }else{
                        max = sec;
                    }
                    if( (currn ^ sec ) > lucky ){
                        lucky = currn ^ sec;
                    }
                    if(highest.find(k) != highest.end() ){
                        break;
                    }
                }
            }
            cout<<lucky;
            return 0;
        }
    }
    return EXIT_SUCCESS;
}