#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <std::uint_fast64_t Modulus>
class modint {
  using u64 = std::uint_fast64_t;
  u64 a;

 public:
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 val() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr bool operator==(const modint rhs) const noexcept {
    return modint(*this).val() == rhs.val();
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<998244353>;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<string> a(n);
  vector<long long> len(11, 0);
  for (long long i = (0); i < ((n)); ++i) cin >> a[i], len[a[i].size()]++;
  mint ans = 0;
  for (long long i = (0); i < ((n)); ++i) {
    for (long long j = (1); j < (11); ++j) {
      mint tmp = 0, tmp2 = 0;
      for (long long k = (0); k < ((a[i].size())); ++k) {
        if (a[i].size() - k <= j)
          tmp *= 100;
        else
          tmp *= 10;
        tmp += (a[i][k] - '0');
      }
      for (long long k = (0); k < ((a[i].size())); ++k) {
        if (a[i].size() - k < j)
          tmp2 *= 100;
        else
          tmp2 *= 10;
        tmp2 += (a[i][k] - '0');
      }
      tmp2 *= 10;
      ans += (tmp + tmp2) * len[j];
    }
  }
  cout << ans.val() << endl;
  return 0;
}
