#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
vector<int> divide(int x) {
  vector<int> a;
  do {
    a.push_back(x % 10);
    x /= 10;
  } while (x != 0);
  return a;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<vector<int>> digit(n);
  for (int i = 0; i < n; i++) {
    digit[i] = divide(a[i]);
  }
  vector<int> start_length(11, -1);
  for (int i = 0; i < n; i++) {
    if (start_length[digit[i].size()] == -1) {
      start_length[digit[i].size()] = i;
    }
  }
  if (start_length[10] == -1) {
    start_length[10] = 1e9 + 7;
  }
  for (int i = 9; i >= 1; i--) {
    if (start_length[i] == -1) {
      start_length[i] = start_length[i + 1];
    }
  }
  vector<int> pow10(25);
  pow10[0] = 1;
  for (int i = 1; i < 25; i++) {
    pow10[i] = pow10[i - 1] * 10ll % mod;
  }
  vector<int> presum(n + 1);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < digit[i].size(); j++) {
      ans = (ans + 1ll * pow10[2 * j + 1] * (n - i) % mod * digit[i][j] % mod) %
            mod;
      int start_id = start_length[j + 1];
      if (start_id < i) {
        ans = (ans + 1ll * pow10[2 * j + 1] * (i - start_id) % mod *
                         digit[i][j] % mod) %
              mod;
        ans = (ans +
               1ll * pow10[j] * presum[start_id] % mod * digit[i][j] % mod) %
              mod;
      } else {
        ans =
            (ans + 1ll * pow10[j] * presum[i] % mod * digit[i][j] % mod) % mod;
      }
    }
    presum[i + 1] = (presum[i] + pow10[digit[i].size()]) % mod;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < digit[i].size(); j++) {
      ans =
          (ans + 1ll * pow10[2 * j] * (n - i) % mod * digit[i][j] % mod) % mod;
      int start_id = start_length[j + 1];
      if (start_id < i) {
        ans = (ans +
               1ll * pow10[2 * j] * (i - start_id) % mod * digit[i][j] % mod) %
              mod;
        ans = (ans +
               1ll * pow10[j] * presum[start_id] % mod * digit[i][j] % mod) %
              mod;
      } else {
        ans =
            (ans + 1ll * pow10[j] * presum[i] % mod * digit[i][j] % mod) % mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
