#include <bits/stdc++.h>
using namespace std;
long long M = 998244353;
void solve() {
  long long n;
  cin >> n;
  vector<string> v(n);
  vector<long long> cnt(11, 0);
  vector<long long> pow(25, 0);
  pow[0] = 1;
  for (long long i = 1; i <= 24; i++) pow[i] = (pow[i - 1] * 10) % M;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    v[i] = to_string(x);
    cnt[(long long)(v[i].size())]++;
  }
  long long ans = 0, tmp;
  for (long long i = 0; i < n; i++) {
    for (long long j = 1; j <= 10; j++) {
      long long ii = v[i].size();
      long long pp = 0;
      long long ty = 0;
      for (long long k = 0; k < ii + j; k++) {
        if (k < abs(ii - j)) {
          if (ii > j) {
            tmp = (2 * (v[i][pp++] - '0') * pow[ii + j - 1 - k]) % M;
            ty += tmp;
            if (ty >= M) ty -= M;
          } else
            continue;
        } else {
          tmp = ((v[i][pp] - '0') * pow[ii + j - 1 - k]) % M;
          ty += tmp;
          if (ty >= M) ty -= M;
          k++;
          tmp = ((v[i][pp++] - '0') * pow[ii + j - 1 - k]) % M;
          ty += tmp;
          if (ty >= M) ty -= M;
        }
      }
      ty = (ty * cnt[j]) % M;
      ans += ty;
      if (ans >= M) ans -= M;
    }
  }
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  double t1 = clock();
  long long t;
  t = 1;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  cerr << setprecision(10) << (clock() - t1) / CLOCKS_PER_SEC << "\n";
  return 0;
}
