#include <bits/stdc++.h>
using namespace std;
long long key;
int main() {
  int n;
  scanf("%d", &n);
  long long tmp, count_pri[20], prime[20];
  int max_step = 0;
  long long mul[20], ans = 0;
  mul[0] = 1;
  prime[0] = 0;
  count_pri[0] = 0;
  for (int i = 1; i < 20; i++) {
    mul[i] = (mul[i - 1] * 10) % 998244353;
    count_pri[i] = 0;
    prime[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &key);
    tmp = key;
    int step = 0;
    while (tmp) {
      count_pri[step] = count_pri[step] + tmp % 10;
      tmp = tmp / 10;
      step++;
    }
    max_step = max(max_step, step);
    prime[step]++;
  }
  int t = n;
  for (int i = 0; i < max_step; i++) {
    ans =
        (ans + ((((count_pri[i] * mul[i * 2]) % 998244353) * t) % 998244353)) %
        998244353;
    ans = (ans +
           ((((count_pri[i] * mul[i * 2 + 1]) % 998244353) * t) % 998244353)) %
          998244353;
    for (int j = i - 1; j >= 0; j--) {
      ans =
          (ans + count_pri[i] * mul[i + j + 1] * 2 * prime[j + 1]) % 998244353;
    }
    t = t - prime[i + 1];
  }
  printf("%lld\n", ans);
  return 0;
}
