#include <bits/stdc++.h>
using namespace std;
ifstream in ( "xormax.in" );
ofstream out( "xormax.out" );
int N, X, XOR, MAX, val, pos, st, dr;
struct T {
int cntC, cntN, pos;
T *ch[2];
T() {
this -> cntC = this -> cntN = this -> pos = 0;
this -> ch[0] = this -> ch[1] = NULL;
}
} *root = new T;
void insert( T *&t, int X, int p, int pos ) {
if( p < 0 ) {
t -> cntC ++;
t -> pos = pos;
return;
}
int Z = ((X & (1 << p)) > 0);
if( t -> ch[Z] == NULL ) {
t -> ch[Z] = new T;
t -> cntN ++;
}
insert( t -> ch[Z], X, p - 1, pos );
return;
}
void query( T *&t, int &val, int &pos, int X, int Y, int p ) {
if( t -> cntC > 0 ) {
if( val < (X ^ Y) ) {
val = (X ^ Y);
pos = t -> pos;
} else
if( val == (X ^ Y) ) {
if( pos < t -> pos )
pos = t -> pos;
}
}
if( p < 0 )
return;
int Z = ((X & (1 << p)) > 0);
if( t -> ch[1 - Z] != NULL ) {
query( t -> ch[1 - Z], val, pos, X, Y + (1 << p) * (1 - Z), p - 1 );
return;
}
if( t -> ch[Z - 0] != NULL ) {
query( t -> ch[Z - 0], val, pos, X, Y + (1 << p) * (Z - 0), p - 1 );
return;
}
return;
}
int main( int argc, const char *argv[] ) {
in >> N;
insert( root, XOR, 30, 0 );
for( int i = 1; i <= N; i ++ ) {
in >> X; XOR ^= X; val = 0;
query( root, val, pos, X, 0, 30 );
insert( root, XOR, 30, i );
if( MAX < val ) {
MAX = val;
st = pos + 1;
dr = i;
}
}
out << MAX << " " << st << " " << dr << "\n";
return 0;
}