#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; } string f2(string a) { string res = ""; bool f = false; for (int i = 0; i < a.size(); ++i) { if (a[i] != '0') f = true; if (f) res += a[i]; } return res; } int main() { int N; cin >> N; for (int i = 0; i < N; ++i) { cin >> V[i]; V[i] = f2(V[i]); } sort(V, V + N); stable_sort(V, V + N, cmpr); string a = V[0]; cout << f1(V[0]) << endl; }