#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 7, inf = 1e18 + 7, mod = 998244353;
long long tc, n, m, x, a, b, c, d, i, j, k, l, id, sum, cnt, ans, tmp, flag, mn,
    mx;
long long ar[15], br[15];
string s[N];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    br[s[i].size()]++;
    if (s[i].size() > mx) mx = s[i].size();
  }
  for (i = 1; i < 11; i++) br[i] += br[i - 1];
  for (i = 0; i < n; i++) {
    for (j = s[i].size() - 1, k = 0; j >= 0; j--, k++) {
      ar[2 * k + 1] += (s[i][j] - '0') * (n - br[k]);
      ar[2 * k] += (s[i][j] - '0') * (n + br[k]);
    }
  }
  for (i = 0; i < 2 * mx; i++) {
    ar[i + 1] += ar[i] / 10;
    ar[i] %= 10;
  }
  while (ar[i]) {
    ar[i + 1] += ar[i] / 10;
    ar[i] %= 10;
    i++;
  }
  for (j = 0, k = 1; j < i; j++, k = (k * 10) % mod) {
    ans = (ans + (ar[j] * k) % mod) % mod;
  }
  cout << ans << endl;
}
