/*****/ #include #include using namespace atcoder; using namespace std; typedef long long ll; typedef pair P; #define rep(i,a,b) for(int i=a;i=b;i--) #define all(x) begin(x),end(x) const int MOD = 1e9 + 7; const int mod = 998244353; templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } /*****/ int n; ll a[200009]; int main() { cin >> n; vector> pll; rep(i,0,n) { cin >> a[i]; pll.push_back(make_pair(to_string(a[i]), a[i])); } sort(all(pll),[](const pair&a, const pair &b) { if (a.first.length() == b.first.length()) return a.second < b.second; return a.first.length() < b.first.length(); }); ll ans = 0; for (auto& [s,num]:pll) { ans = (ans*10+num)%mod; } cout << ans << endl; }