#include <bits/stdc++.h>
using namespace std;
const int N = 200042;
const int m = 998244353;
int add(int x, int y) {
  x += y;
  while (x >= m) x -= m;
  while (x < 0) x += m;
  return x;
}
int mul(int x, int y) { return (x * 1ll * y) % m; }
int binpow(int x, int y) {
  int z = 1;
  while (y) {
    if (y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
int inv(int x) { return binpow(x, m - 2); }
int divide(int x, int y) { return mul(x, inv(y)); }
int fact[N];
void precalc() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
}
int C(int n, int k) { return divide(fact[n], mul(fact[k], fact[n - k])); }
int A(int n, int m) { return divide(fact[n], fact[n - m]); }
int get(string s, int len) {
  int res = 0;
  int sz = s.size();
  for (int i = 0; i < min(sz, len); i++) {
    res = add(res, mul(s[i] - '0', binpow(10, 2 * i)));
    res = add(res, mul(s[i] - '0', binpow(10, 2 * i + 1)));
  }
  int curp = binpow(10, 2 * (min(sz, len)));
  for (int i = 0; i < sz - min(sz, len); i++) {
    res = add(res, mul(s[i + min(sz, len)] - '0', curp));
    res = add(res, mul(s[i + min(sz, len)] - '0', curp));
    curp = mul(curp, 10);
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  precalc();
  int n = 0;
  cin >> n;
  int ans = 0;
  vector<string> s(n);
  int sizes[12] = {0};
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    reverse((s[i]).begin(), (s[i]).end());
    sizes[s[i].size()]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < 10; j++) {
      ans = add(ans, mul(get(s[i], j), sizes[j]));
    }
  }
  cout << ans;
  return 0;
}
