/* -*- coding: utf-8 -*- * * 2734.cc: No.2734 Addition and Multiplication in yukicoder (Hard) - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int MAX_L = 20; const int MOD = 998244353; /* typedef */ typedef long long ll; /* global variables */ string as[MAX_N]; /* subroutines */ bool cmpstr(const string &a, const string &b) { return (a + b) < (b + a); } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { char s[MAX_L + 4]; scanf("%s", s); as[i] = string(s); } sort(as, as + n, cmpstr); int sum = 0; for (int i = 0; i < n; i++) for (auto c: as[i]) sum = ((ll)sum * 10 + (c - '0')) % MOD; printf("%d\n", sum); return 0; }