#include <bits/stdc++.h>
using namespace std;
const int NIL = -1;
template <class T>
inline T mx(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T mi(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline void sw(T &a, T &b) {
  T t = a;
  a = b;
  b = t;
}
template <class T>
inline T mabs(T x) {
  return x < 0 ? -x : x;
}
inline char gc() {
  char ret;
  while ((ret = getchar()) == ' ' || ret == '\n' || ret == '\t')
    ;
  return ret;
}
template <class T>
inline T sq(T x) {
  return x * x;
}
const long long MOD = 998244353ll;
long long b[20];
inline long long mul(long long a, long long b) {
  return (a % MOD) * (b % MOD) % MOD;
}
inline long long add(long long a, long long b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}
const int LIM = 1e5 + 10;
long long dat[LIM];
long long cnt[20], dif[20];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  b[0] = 1;
  for (int i = 1; i < 20; i++) b[i] = mul(b[i - 1], 10);
  long long n, x;
  long long ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> dat[i];
    x = dat[i];
    int cur = 0;
    while (x) dif[cur++]++, x /= 10;
    cnt[cur - 1]++;
  }
  for (int i = 0; i < n; i++) {
    x = dat[i];
    int cur = 0;
    while (x) {
      ans = add(ans, mul(b[cur << 1], mul(dif[cur], x % 10)));
      ans = add(ans, mul(b[(cur << 1) + 1], mul(dif[cur], x % 10)));
      for (int j = 0; j < cur; j++)
        ans = add(ans, mul(b[cur + j + 1], mul(mul(cnt[j], 2), x % 10)));
      cur++;
      x /= 10;
    }
  }
  cout << ans;
  return 0;
}
