#include using namespace std; typedef long long ll; string V[1000]; bool cmpr(string a, string b) { return a.size() < b.size(); } long long f1(string a) { int b; char maxc = 0; for (int i = 0; i < a.size(); ++i) maxc = max(maxc, a[i]); b = (isdigit(maxc) ? maxc - '0' + 1 : maxc - 'A' + 11); ll c = 1; ll res = 0; for (int i = a.size() - 1; i >= 0; --i) { res += (isdigit(a[i]) ? a[i] - '0' : a[i] - 'A' + 10) * c; c *= b; } return res; } int main() { int N; cin >> N; for (int i = 0; i < N; ++i) cin >> V[i]; ll mi = LLONG_MAX; for (int i = 0; i < N; ++i) mi = min(mi, f1(V[i])); cout << mi << endl; }