#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 998244353;
constexpr int MAXN = 1e5 + 10;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
ll N, M, K, T;
ll A[MAXN];
ll memos[2][MAXN][15];
inline ll Add(ll a, ll b) { return (a + b) % MOD; }
void Helper(ll base, ll i, ll j) {
  int g = base == 1 ? 0 : 1;
  ll x = 0;
  ll num = A[i];
  ll k = g;
  while (num != 0) {
    ll dig = num % 10;
    x = Add(x, dig * base % MOD);
    base *= (k < j ? 100 : 10);
    base %= MOD;
    num /= 10;
    ++k;
  }
  memos[g][i][j] = x;
}
ll Solution() {
  for (int i = (int)(0); i < (int)(N); ++i) {
    for (int j = (int)(1); j < (int)(11); ++j) {
      Helper(1, i, j);
      Helper(10, i, j);
    }
  }
  map<int, ll> cnts;
  for (int i = (int)(0); i < (int)(N); ++i) {
    int k = 0;
    ll num = A[i];
    while (num != 0) {
      ++k;
      num /= 10;
    }
    cnts[k]++;
  }
  ll ans = 0;
  for (int i = (int)(0); i < (int)(N); ++i) {
    for (auto &p : cnts) {
      ans = Add(ans, memos[0][i][p.first] * p.second % MOD);
      ans = Add(ans, memos[1][i][p.first] * p.second % MOD);
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  while (cin >> N) {
    for (int i = (int)(0); i < (int)(N); ++i) {
      cin >> A[i];
    }
    cout << Solution() << '\n';
  }
  return 0;
}
