#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = (int)2e5 + 5;
const long long mod = 998244353;
long long n, a[MAXN], cnt[MAXN][25], sum[25], fac[25] = {1LL}, len[MAXN];
int main() {
  for (int i = 1; i <= 24; i++) fac[i] = fac[i - 1] * 10 % mod;
  while (~scanf("%lld", &n)) {
    memset(len, 0, sizeof(len));
    memset(cnt, 0, sizeof(cnt));
    memset(sum, 0, sizeof(sum));
    ;
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      int pos = 0;
      long long temp = a[i];
      while (temp) {
        cnt[i][pos++] = temp % 10;
        temp /= 10;
      }
      sum[pos - 1]++;
      len[i] = pos;
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= 10; j++) {
        for (int k = 0; k <= 10; k++) {
          if (cnt[i][j]) {
            if (j > k) {
              ans += cnt[i][j] * sum[k] % mod * fac[j + k + 1] % mod * 2 % mod;
              ans %= mod;
            }
            if (j <= k) {
              ans += cnt[i][j] * sum[k] % mod * fac[j * 2] % mod;
              ans += cnt[i][j] * sum[k] % mod * fac[j * 2 + 1] % mod;
              ans %= mod;
            }
          }
        }
      }
    }
    ans %= mod;
    ans += mod;
    ans %= mod;
    printf("%lld\n", ans);
  }
  return 0;
}
