#include <bits/stdc++.h>
using namespace std;
const long long md = 998244353;
long long ret(string s, int cnt, int n) {
  long long ret = 0;
  if (cnt >= s.size()) {
    long long num = 1;
    long long tmp = 0;
    for (int j = 0; j < s.size(); ++j) {
      tmp = (s[j] - '0') * num;
      num *= 100;
      num %= md;
      tmp %= md;
      ret = (ret + tmp * n % md) % md;
    }
    tmp = 0;
    num = 10;
    for (int j = 0; j < s.size(); ++j) {
      tmp = (s[j] - '0') * num;
      num *= 100;
      num %= md;
      tmp %= md;
      ret = (ret + tmp * n % md) % md;
    }
  } else {
    long long num = 1;
    long long tmp = 0;
    for (int j = 0; j < s.size(); ++j) {
      tmp = (s[j] - '0') * num;
      num *= 100;
      if (j >= cnt) num /= 10;
      num %= md;
      tmp %= md;
      ret = (ret + tmp * n % md) % md;
    }
    num = 10;
    tmp = 0;
    for (int j = 0; j < s.size(); ++j) {
      tmp = (s[j] - '0') * num;
      num *= 100;
      if (j >= cnt - 1) num /= 10;
      num %= md;
      tmp %= md;
      ret = (ret + tmp * n % md) % md;
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0), cout.precision(10);
  int nn;
  cin >> nn;
  long long tmp, num = 1, ans = 0;
  vector<string> str;
  int cnt[15] = {0};
  for (int i = 1; i <= nn; ++i) {
    string ss;
    cin >> ss;
    reverse(ss.begin(), ss.end());
    cnt[ss.size()]++;
    str.push_back(ss);
  }
  long long x;
  for (string s : str) {
    for (int i = 1; i < 11; ++i) {
      x = 0;
      x = ret(s, i, cnt[i]);
      x %= md;
      ans = (ans + x) % md;
    }
  }
  cout << ans % md << endl;
  return 0;
}
