#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const long long mod = 998244353ll;
long long ans;
stack<int> s;
int n, dig[20], p, da[maxn], len[maxn], num[20], sum[20][20];
long long cal(int q) {
  long long ret = 0ll;
  int x;
  if (p >= q) {
    for (int i = 1; i <= p - q + 1; ++i) s.push(1);
    for (int i = 1; i <= q; ++i) {
      s.push(2);
      if (i < q) s.push(1);
    }
  } else {
    for (int i = 1; i <= q - p; ++i) s.push(2);
    for (int i = 1; i <= p; ++i) s.push(1), s.push(2);
  }
  long long pro = 1ll;
  int tp = 1, tq = 1;
  while (s.size() > 0) {
    x = s.top();
    s.pop();
    if (x == 1)
      (ret += dig[tp++] * pro % mod * num[q] % mod) %= mod;
    else
      (ret += sum[q][tq++] * pro % mod) %= mod;
    pro = pro * 10ll % mod;
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, pp; i <= n; ++i) {
    scanf("%d", &da[i]);
    x = da[i];
    while (x) {
      ++len[i];
      x /= 10;
    }
    ++num[len[i]];
    x = da[i];
    pp = 0;
    while (x) {
      sum[len[i]][++pp] += x % 10;
      x /= 10;
    }
  }
  for (int i = 1; i <= n; ++i) {
    p = 0;
    while (da[i]) {
      dig[++p] = da[i] % 10;
      da[i] /= 10;
    }
    for (int j = 1; j <= 10; ++j)
      if (num[j]) {
        (ans += cal(j)) %= mod;
      }
  }
  cout << ans << endl;
  return 0;
}
