#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printv(vector<T> v) {
  for (auto e : v) {
    cout << e << " ";
  }
  cout << "\n";
}
template <typename T>
void printvv(vector<T> vv) {
  for (long long i = 0; i < vv.size(); i++) {
    cout << i << ": ";
    for (auto e : vv[i]) {
      cout << e << " ";
    }
    cout << "\n";
  }
}
long long t, n, m, k, x, y;
vector<long long> a, b, c;
const long long p = 998244353;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  a.resize(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  b.resize(n);
  for (long long i = 0; i < n; i++) {
    string s = to_string(a[i]);
    b[i] = s.size();
  }
  vector<long long> len(11);
  for (long long i = 0; i < n; i++) {
    len[b[i]]++;
  }
  vector<long long> prelen(11);
  for (long long i = 1; i < 11; i++) {
    prelen[i] = prelen[i - 1] + len[i];
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long temp = 0;
    long long num = a[i];
    long long m = b[i];
    long long prod = 1;
    long long greater = prelen[10] - prelen[m - 1];
    for (long long j = 0; j < m; j++) {
      long long rem = num % 10;
      temp += (((rem * 11) % p) * prod) % p;
      temp %= p;
      prod *= 100;
      prod %= p;
      num /= 10;
    }
    temp = (temp * greater) % p;
    ans = (ans + temp) % p;
    for (long long k = 1; k < m; k++) {
      temp = 0;
      long long prod = 1;
      num = a[i];
      for (long long j = 0; j < k; j++) {
        long long rem = num % 10;
        temp += (((rem * 11) % p) * prod) % p;
        temp %= p;
        prod *= 100;
        prod %= p;
        num /= 10;
      }
      temp += (2 * (num * prod)) % p;
      temp %= p;
      temp = (temp * len[k]) % p;
      ans = (ans + temp) % p;
    }
  }
  cout << ans << "\n";
}
