#include using namespace std; signed main(){ int N; cin >> N; vector< string > A( N ); for( int i = 0; i < N; ++i ) cin >> A[ i ]; long long ans = 1LL << 62; for( int i = 0; i < N; ++i ){ int base = 0; for( int j = 0; j < A[ i ].size(); ++j ) base = max( base, A[ i ][ j ] <= '9' ? A[ i ][ j ] - '0' + 1 : A[ i ][ j ] - 'A' + 10 + 1 ); for( int j = 0; j < A[ i ].size(); ++j ) if( A[ i ][ j ] >= 'A' ) A[ i ][ j ] = A[ i ][ j ] - 'A' + 'a'; ans = min( ans, stoll( A[ i ], nullptr, base ) ); } cout << ans << endl; return 0; }