#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef long double ld; typedef pair P; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const static_modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const dynamic_modint& a) {os << a.val(); return os;} template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} using mint = modint998244353; int main(){ int n; cin >> n; vector a(n); cin >> a; sort(a.begin(), a.end(), [](long long left, long long right){ string s_left = to_string(left); string s_right = to_string(right); string s_left_right = s_left + s_right; string s_right_left = s_right + s_left; return s_left_right < s_right_left; }); mint ans = 0; rep(i, n){ int d = to_string(a[i]).size(); ans *= mint(10).pow(d); ans += a[i]; } cout << ans << "\n"; return 0; }