#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp, c, t, md;
  long long int kel, kel2, res = 0;
  vector<int> count(11, 0), sum(11, 0);
  md = 998244353;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    t = 0;
    while (temp > 0) {
      c = temp % 10;
      t++;
      sum[t] += c;
      temp /= 10;
    }
    count[t]++;
  }
  for (int i = 1; i < 11; i++) {
    kel = pow(10, 2 * (i - 1));
    kel2 = kel * 10;
    for (int j = 10; j > 0; j--) {
      if (j < i - 1) {
        kel /= 10;
      }
      if (j < i) {
        kel2 /= 10;
      }
      res += count[j] * sum[i] * kel2;
      res += count[j] * sum[i] * kel;
      res %= md;
    }
  }
  cout << res;
  return 0;
}
