#include #include #include #include #include #include #include #include #define REP(i,k,n) for(int i=k;i P; int ch(char c) { if('0' <= c && c <= '9') { return c - '0'; } else { return c - 'A' + 10; } } int main() { int n; cin >> n; ll ans = -1; rep(i,n) { string s; cin >> s; int vmax = 0; rep(j,s.size()) vmax = max(vmax, ch(s[j])); ll cnt = 0; ll t = 1; for(int j=s.size()-1;j>=0;j--) { cnt += ch(s[j]) * t; t *= (vmax + 1); } if(ans == -1) ans = cnt; else ans = min(ans,cnt); } cout << ans << endl; return 0; }