#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long mod = 998244353LL;
int n;
int bin[15];
string s[maxn];
long long t[25], suf[25];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  sort(s, s + n, [](const string &a, const string &b) {
    return a.length() < b.length();
  });
  t[0] = 1;
  for (int i = 1; i < 25; ++i) t[i] = t[i - 1] * 10 % mod;
  long long ans = 0, pre = 0, num = 0;
  int pt = 0;
  for (int i = 0; i < n; ++i) {
    int len = s[i].length();
    for (int j = 1; j <= len; ++j) {
      if (bin[j] == 0) continue;
      long long num = 0;
      int pt = 1;
      for (int k = 0; k < len; ++k) {
        num = (num + (s[i][len - k - 1] - '0') * t[pt]) % mod;
        pt += (k + 1 < j) ? 2 : 1;
      }
      ans = (ans + num * bin[j] % mod) % mod;
    }
    ans = (ans + pre) % mod;
    num = 0, pt = 0;
    for (int j = 0; j < len; ++j) {
      num = (num + (s[i][len - j - 1] - '0') * t[pt]) % mod;
      pt += 2;
    }
    pre = (pre + num) % mod;
    ++bin[len];
  }
  for (int i = n - 1; i >= 0; --i) {
    num = 0;
    int len = s[i].length(), pt = 1;
    for (int j = 0; j < len; ++j) {
      num = (num + (s[i][len - j - 1] - '0') * t[pt]) % mod;
      pt += 2;
    }
    ans = (ans + (num * (n - i - 1)) % mod + suf[len]) % mod;
    for (int j = 1; j <= len; ++j) {
      num = 0, pt = 0;
      for (int k = 0; k < len; ++k) {
        num = (num + (s[i][len - k - 1] - '0') * t[pt]) % mod;
        pt += (k < j) ? 2 : 1;
      }
      suf[j] = (suf[j] + num) % mod;
    }
  }
  for (int i = 0; i < n; ++i) {
    num = 0;
    int len = s[i].length();
    for (int j = 0; j < len; ++j) {
      num = (num * 100 + (s[i][j] - '0') * 11) % mod;
    }
    ans = (ans + num) % mod;
  }
  cout << ans << endl;
  return 0;
}
