#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MOD = 998244353;
template <class T>
inline void chmax(T &a, const T &b) {
  if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
  if ((a) > (b)) (a) = (b);
}
template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
long long solve() {
  long long n;
  cin >> n;
  vector<string> a(n);
  vector<long long> dcnt(11, 0);
  for (long long i = (long long)(0); i < (long long)(n); ++i) {
    cin >> a[i];
    dcnt[((long long)(a[i]).size())]++;
  }
  42;
  42;
  auto f = [&](string s, long long d) {
    long long m = ((long long)(s).size());
    long long res = 0;
    long long mul = 1;
    long long cnt = 0;
    for (long long i = (long long)((m)-1); i >= (long long)(0); --i) {
      long long x = s[i] - '0';
      res += mul * x;
      if (cnt < d) {
        mul *= 100;
      } else {
        mul *= 10;
      }
      mul %= MOD;
      res %= MOD;
      cnt++;
    }
    return res;
  };
  42;
  auto g = [&](string s, long long d) {
    long long m = ((long long)(s).size());
    long long res = 0;
    long long mul = 10;
    long long cnt = 0;
    for (long long i = (long long)((m)-1); i >= (long long)(0); --i) {
      long long x = s[i] - '0';
      res += mul * x;
      if (cnt < d - 1) {
        mul *= 100;
      } else {
        mul *= 10;
      }
      mul %= MOD;
      res %= MOD;
      cnt++;
    }
    return res;
  };
  42;
  long long ans = 0;
  for (long long i = (long long)(0); i < (long long)(n); ++i) {
    for (long long d = (long long)(1); d < (long long)(11); ++d) {
      ans += f(a[i], d) * dcnt[d];
      ans += g(a[i], d) * dcnt[d];
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
signed main() {
  solve();
  return 0;
}
