#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const long long M = 998244353;
int n, a[N], pos[N], num[N], digits;
long long p[N];
void init() {
  digits = 1;
  p[1] = 1;
  for (int i = 1; i <= n; i++) {
    while (digits < 10 && a[i] >= p[digits] * 10) {
      digits++;
      p[digits] = p[digits - 1] * 10;
      pos[digits - 1] = i - 1;
    }
    num[i] = digits;
  }
  pos[digits] = n;
  while (digits < 20) {
    ++digits;
    p[digits] = p[digits - 1] * 10 % M;
    pos[digits] = n;
  }
  for (int i = 1; i <= digits; i++) p[i] %= M;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  init();
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    int j = 0;
    int tmp = a[i];
    while (tmp) {
      j++;
      for (int k = 1; k <= num[n]; k++) {
        res += (tmp % 10) * (p[j + min(j - 1, k)] + p[j + min(j, k)]) % M *
               (pos[k] - pos[k - 1]) % M;
        res %= M;
      }
      tmp /= 10;
    }
  }
  cout << res;
  return 0;
}
