#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)998244353;
const int mx = (int)1e5 + 10;
long long arr[mx], l[16], pl[mx];
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  long long sum = 0LL;
  int len = 0;
  int hi = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    long long temp = arr[i];
    len = 0;
    while (temp > 0) {
      temp /= 10;
      len++;
    }
    pl[i] = len;
    l[len]++;
    hi = max(hi, len);
  }
  for (int i = 0; i < n; ++i) {
    long long temp = arr[i];
    vector<int> v;
    while (temp > 0) {
      v.push_back(temp % 10);
      temp /= 10;
    }
    for (int j = 1; j <= hi; ++j) {
      if (pl[i] == j) {
        long long res1 = 0, res2 = 0;
        for (int kk = 1, in = 0; in < pl[i]; kk += 2, ++in) {
          long long tmp1 = (bigmod(10, kk, mod) * v[in]) % mod;
          long long tmp2 = (bigmod(10, kk - 1, mod) * v[in]) % mod;
          res1 = (res1 + tmp1) % mod;
          res2 = (res2 + tmp2) % mod;
        }
        long long tt1 = ((res1 % mod) * (l[j] % mod)) % mod;
        long long tt2 = ((res2 % mod) * (l[j] % mod)) % mod;
        sum = (sum + tt1 + tt2) % mod;
      } else if (pl[i] > j) {
        long long res1 = 0, res2 = 0;
        int in = 0, kk;
        for (kk = 1; in < j; kk += 2, ++in) {
          long long tmp1 = (bigmod(10, kk, mod) * v[in]) % mod;
          long long tmp2 = (bigmod(10, kk - 1, mod) * v[in]) % mod;
          res1 = (res1 + tmp1) % mod;
          res2 = (res2 + tmp2) % mod;
        }
        kk -= 1;
        while (in < pl[i]) {
          long long tmp1 = (bigmod(10, kk, mod) * v[in]) % mod;
          long long tmp2 = (bigmod(10, kk, mod) * v[in]) % mod;
          res1 = (res1 + tmp1) % mod;
          res2 = (res2 + tmp2) % mod;
          in++;
          kk++;
        }
        long long tt1 = ((res1 % mod) * (l[j] % mod)) % mod;
        long long tt2 = ((res2 % mod) * (l[j] % mod)) % mod;
        sum = (sum + tt1 + tt2) % mod;
      } else if (pl[i] < j) {
        long long res1 = 0, res2 = 0;
        int k, kk;
        for (k = 0, kk = 1; k < pl[i]; ++k, kk += 2) {
          long long tmp1 = (bigmod(10, kk, mod) * v[k]) % mod;
          long long tmp2 = (bigmod(10, kk - 1, mod) * v[k]) % mod;
          res1 = (res1 + tmp1) % mod;
          res2 = (res2 + tmp2) % mod;
        }
        long long tt1 = ((res1 % mod) * (l[j] % mod)) % mod;
        long long tt2 = ((res2 % mod) * (l[j] % mod)) % mod;
        sum = (sum + tt1 + tt2) % mod;
      }
    }
  }
  cout << sum << '\n';
  return 0;
}
