#include <bits/stdc++.h>
using namespace std;
long long p[31];
int a[100001];
int b[100001];
int num[11];
int n, i, j, k, l;
long long ans, s;
int main() {
  p[1] = 1;
  for (i = 2; i <= 30; i++) p[i] = p[i - 1] * 10 % 998244353;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    j = a[i];
    k = 0;
    while (j) {
      j /= 10;
      ++k;
    }
    ++num[k];
    b[i] = k;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= 10; j++) {
      s = 0;
      if (b[i] >= j) {
        k = a[i];
        for (l = 1; l <= j; l++) {
          s = (s + p[l * 2] * (k % 10)) % 998244353;
          k /= 10;
        }
        l = j * 2;
        while (k) {
          ++l;
          s = (s + p[l] * (k % 10)) % 998244353;
          k /= 10;
        }
      } else {
        k = a[i];
        for (l = 1; l <= b[i]; l++) {
          s = (s + p[l * 2] * (k % 10)) % 998244353;
          k /= 10;
        }
      }
      ans = (ans + s * num[j]) % 998244353;
    }
    for (j = 1; j <= 10; j++) {
      s = 0;
      if (b[i] >= j) {
        k = a[i];
        for (l = 1; l <= j; l++) {
          s = (s + p[l * 2 - 1] * (k % 10)) % 998244353;
          k /= 10;
        }
        l = j * 2;
        while (k) {
          ++l;
          s = (s + p[l] * (k % 10)) % 998244353;
          k /= 10;
        }
      } else {
        k = a[i];
        for (l = 1; l <= b[i]; l++) {
          s = (s + p[l * 2 - 1] * (k % 10)) % 998244353;
          k /= 10;
        }
      }
      ans = (ans + s * num[j]) % 998244353;
    }
  }
  printf("%I64d\n", ans);
}
