#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 77, L = 12, Mod = 998244353;
int A, n, a[N], Pow[N], dp[L][L][L][2], T[L];
vector<int> F[N];
inline void fix(int& x) {
  if (x >= Mod) x -= Mod;
}
inline vector<int> Getd(int x) {
  vector<int> V;
  while (x) V.push_back(x % 10), x /= 10;
  return V;
}
int main() {
  Pow[0] = 1;
  for (int i = 1; i < N; ++i) Pow[i] = 10ll * Pow[i - 1] % Mod;
  for (int i = 1; i < L; ++i)
    for (int j = 1; j <= i; ++j) dp[0][i][j][1] = Pow[j - 1];
  for (int i = 1; i < L; ++i)
    for (int j = 1; j < L; ++j)
      for (int k = 1; k < L; ++k) {
        if (j > i) fix(dp[i][j][k][0] += dp[i][j - 1][k][0]);
        if (i >= j) fix(dp[i][j][k][0] += dp[i - 1][j][k][0]);
        if (i >= j && k == i) fix(dp[i][j][k][0] += Pow[i + j - 1]);
        if (j > i) fix(dp[i][j][k][1] += dp[i][j - 1][k][1]);
        if (i >= j) fix(dp[i][j][k][1] += dp[i - 1][j][k][1]);
        if (j > i && k == j) fix(dp[i][j][k][1] += Pow[i + j - 1]);
      }
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", a + i), F[i] = Getd(a[i]), ++T[int(F[i].size())];
  for (int i = 1; i <= n; ++i) {
    int sz = F[i].size();
    for (int j = 0; j < sz; ++j)
      for (int k = 1; k < L; ++k) {
        fix(A += F[i][j] * 1ll * dp[sz][k][j + 1][0] % Mod * 1ll * T[k] % Mod);
        fix(A += F[i][j] * 1ll * dp[k][sz][j + 1][1] % Mod * 1ll * T[k] % Mod);
      }
  }
  printf("%d\n", A);
  return 0;
}
