#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int maxn = 100005;
long long qpow(long long b, long long e) {
  if (!e) return 1;
  if (e & 1) return (qpow(b, e - 1) * b) % mod;
  return qpow((b * b) % mod, e >> 1);
}
string arr[maxn];
long long cnt[maxn], mye[maxn], n;
long long s[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(0);
  cin >> n;
  int mx = -1;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    int m = arr[i].size();
    arr[i] = "$" + arr[i];
    cnt[m]++;
    mx = max(mx, m);
  }
  for (int i = 1; i <= mx; i++) {
    s[i] = s[i - 1];
    s[i] += (qpow(10, i) * cnt[i]) % mod;
    s[i] %= mod;
  }
  for (int i = mx; i >= 0; i--) mye[i] = mye[i + 1] + cnt[i];
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int m = arr[i].size() - 1;
    for (int j = 1; j <= m; j++) {
      long long first = qpow(10, m - j);
      long long t = ((arr[i][j] - '0') * first) % mod;
      t = (t * s[m - j]) % mod;
      ans = (ans + 2ll * t) % mod;
      t = ((arr[i][j] - '0') * first) % mod;
      t = (t * mye[m - j + 1]) % mod;
      t = (t * first) % mod;
      ans = (ans + t) % mod;
      t = (t * 10ll) % mod;
      ans = (ans + t) % mod;
    }
  }
  cout << ans;
  return 0;
}
