#include using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef pair< int, int > pii; typedef vector< pii > vp; typedef vector< double > vd; typedef vector< vd > vvd; typedef vector< string > vs; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; int N; vi A; void init(){ cin >> N; A = vi( N ); for( int i = 0; i < N; ++i ){ cin >> A[ i ]; } } struct trie{ trie *ch[ 2 ]; trie(){ ch[ 0 ] = ch[ 1 ] = NULL; } } *root; void update( trie *&t, int lv, int v ){ if( lv < 0 ){ return; } if( t->ch[ v >> lv & 1 ] == NULL ){ t->ch[ v >> lv & 1 ] = new trie(); } update( t->ch[ v >> lv & 1 ], lv - 1, v ); } void preprocess(){ root = new trie(); for( int i = 0; i < N; ++i ){ update( root, 30, A[ i ] ); } } int dfs( const trie *t, int lv ){ if( lv < 0 ){ return 0; } if( t->ch[ 0 ] == NULL ){ return dfs( t->ch[ 1 ], lv - 1 ); } if( t->ch[ 1 ] == NULL ){ return dfs( t->ch[ 0 ], lv - 1 ); } return 1 << lv | min( dfs( t->ch[ 0 ], lv - 1 ), dfs( t->ch[ 1 ], lv - 1 ) ); } void solve(){ cout << dfs( root, 30 ) << endl; } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }