#include #include #include using namespace std; typedef unsigned long long ULL; int main() { int n; cin >> n; ULL ans = 1ULL << 63; for (int i = 0; i < n; i++){ string s; cin >> s; int d = 2; for (int j = 0; j < s.size(); j++){ if (isalpha(s[j])) s[j] = s[j] - 'A' + 10; else s[j] -= '0'; d = max(d, (int)s[j]); } d++; ULL num = 0, mul = 1; for (int j = s.size() - 1; j >= 0; j--, mul *= d){ num += s[j] * mul; } ans = min(ans, num); } printf("%ulld\n", ans); return 0; }