#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<string> a((size_t)n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    reverse(a[i].begin(), a[i].end());
  }
  vector<long long> ten_power((size_t)100, 1);
  for (long long i = 1; i < ten_power.size(); i++) {
    ten_power[i] = ten_power[i - 1] * 10;
    ten_power[i] %= 998244353;
  }
  vector<long long> b((size_t)10 + 1, 0);
  for (string &s : a) {
    b[s.size()]++;
  }
  long long o = 0;
  for (string &s : a) {
    for (long long i = 0; i < s.size(); i++) {
      for (long long j = 1; j <= 10; j++) {
        o += (s[i] - '0') * b[j] *
             (j > i ? (ten_power[i * 2] + ten_power[i * 2 + 1])
                    : (ten_power[i + j] * 2));
        o %= 998244353;
      }
    }
  }
  o %= 998244353;
  cout << o << endl;
  return 0;
}
