#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using pairll = pair<ll, ll>;
using vvll = vector<vll>;
using vint = vector<int>;
using pint = pair<int, int>;
using vvint = vector<vint>;
ll power(ll a, ll b) {
  if (b == 0) {
    return 1;
  }
  if (b % 2 == 0) {
    ll res = power(a, b / 2);
    return (res * res) % 998244353;
  }
  return (a * (power(a, b - 1))) % 998244353;
}
ll n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  ll sum = 0, x, dex, q;
  vll v(11, 0), a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v[ceil(log10(a[i] + 1))]++;
  }
  for (int i = 0; i < n; i++) {
    x = a[i];
    dex = 1;
    while (x != 0) {
      q = x % 10;
      for (ll j = 1; j <= 10; j++) {
        sum += q * power(10, min(2 * dex, dex + j) - 1) * v[j];
        sum %= 998244353;
        sum += q * power(10, min(2 * dex - 1, dex + j) - 1) * v[j];
        sum %= 998244353;
      }
      x /= 10;
      dex++;
    }
  }
  sum %= 998244353;
  cout << sum << '\n';
}
