// #define _GLIBCXX_DEBUG #include using namespace std; using uint = unsigned int; using ll = long long; #define CIN( LL , A ) LL A; cin >> A #define GETLINE( A ) string A; getline( cin , A ) #define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR ) #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( ll VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; return 0 #define DOUBLE( PRECISION , ANSWER ) cout << fixed << setprecision( PRECISION ) << ( ANSWER ) << "\n"; return 0 #define MIN( A , B ) A < B ? A : B; #define MAX( A , B ) A < B ? B : A; template inline T Absolute( const T& a ){ return a > 0 ? a : - a; } int main() { UNTIE; CIN( ll , N ); constexpr const ll power = 65536; constexpr const ll digit = 16; if( N >= digit ){ RETURN( power - 1 ); } constexpr const ll shift = power / 2; ll Ai; bool c[power] = {}; ll answer[2][power]; answer[0][0] = 0; ll size[2] = { 1 , 0 }; ll signature_last = 0; ll signature_new = 1; ll value; N--; REPEAT( N ){ cin >> Ai; ll ( &answer_last )[power] = answer[signature_last]; ll& size_last = size[signature_last]; ll ( &answer_new )[power] = answer[signature_new]; ll& size_new = size[signature_new]; size_new = 0; REPEAT( digit ){ FOR( j , 0 , size_last ){ value = answer_last[j] | Ai; if( ! c[value] ){ c[value] = true; answer_new[size_new] = value; size_new++; } } Ai = shift * ( Ai % 2 ) + Ai / 2; } if( size_new == 0 ){ RETURN( power - 1 ); } swap( signature_last , signature_new ); } ll max = -1; { cin >> Ai; ll ( &answer_last )[power] = answer[signature_last]; ll& size_last = size[signature_last]; REPEAT( digit ){ FOR( j , 0 , size_last ){ value = answer_last[j] | Ai; if( ! c[value] ){ c[value] = true; if( max < value ){ max = value; } } } Ai = shift * ( Ai % 2 ) + Ai / 2; } if( max == -1 ){ RETURN( power - 1 ); } } RETURN( max ); }