#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int fx[] = {+1, -1, +0, +0};
const int fy[] = {+0, +0, +1, -1};
long long int ans = 0;
long long int power(long long int x, long long int y, long long int m) {
  if (y == 0) return 1;
  long long int p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  vector<string> data;
  vector<long long int> lengths(11, 0);
  for (long long int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    data.push_back(tmp);
    lengths[(long long int)tmp.length()]++;
  }
  vector<long long int> sums(21, 0);
  for (long long int i = 0; i < n; i++) {
    long long int j = 0;
    while (j < (long long int)data[i].length()) {
      long long int k = 1;
      while (k < (long long int)lengths.size()) {
        long long int f = (long long int)data[i].length() - j;
        if (k >= f) {
          sums[2 * f] += (data[i][j] - '0') * lengths[k];
          sums[2 * f] %= 998244353;
        } else {
          sums[f + k] += (data[i][j] - '0') * lengths[k];
          sums[f + k] %= 998244353;
        }
        if (k >= f - 1) {
          sums[(2 * f) - 1] += (data[i][j] - '0') * lengths[k];
          sums[(2 * f) - 1] %= 998244353;
        } else {
          sums[f + k] += (data[i][j] - '0') * lengths[k];
          sums[f + k] %= 998244353;
        }
        k++;
      }
      j++;
    }
  }
  for (long long int i = 0; i < (long long int)sums.size(); i++) {
    if (i == 0) {
      continue;
    }
    ans += sums[i] * power(10, i - 1, 998244353);
    ans %= 998244353;
  }
  cout << ans;
  return 0;
}
