#include #include #include #include using namespace std; using ll = long long; bool comp(string a, string b) { return a + b < b + a; } ll mod = 998244353; int main() { ll N; cin >> N; vector A(N); for (ll i = 0; i < N; i++) { cin >> A[i]; } vector pow_d(19); pow_d[0] = 1; for (ll i = 0; i < 18; i++){ pow_d[i + 1] = pow_d[i] * 10; } vector pow_10(19); pow_10[0] = 1; for (ll i = 0; i < 18; i++) { pow_10[i + 1] = (pow_10[i] * 10LL) % mod; } vector> vec(N); for (ll i = 0; i < N; i++){ ll len = to_string(A[i]).size(); vec[i].first = (long double)(A[i]) / (pow_10[len] - 1); vec[i].second = A[i]; } sort(vec.begin(), vec.end()); ll ans = 0; for (ll i = 0; i < N; i++) { ll as_val = vec[i].second; ll len = to_string(as_val).size(); ans = (ans * pow_10[len]) % mod; ans = (ans + as_val % mod) % mod; } cout << ans << endl; }