#include <bits/stdc++.h>
using namespace std;
unsigned long long separate(unsigned long long x, int len) {
  unsigned long long res = 0;
  unsigned long long power10 = 1;
  int count = 0;
  for (; x > 0; x = x / 10, count++) {
    res += x % 10 * power10;
    if (count < len) {
      power10 *= 100;
    } else {
      power10 *= 10;
    }
  }
  return res;
}
int findLen(unsigned long long x) {
  int res = 0;
  for (; x > 0; x = x / 10, res++)
    ;
  return res;
}
int main() {
  int n;
  cin >> n;
  unsigned long long x;
  unsigned long long s = 0;
  map<int, int> lens;
  vector<unsigned long long> a;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
    int l = findLen(x);
    if (lens.find(l) != lens.end()) {
      lens.at(l)++;
    } else {
      lens.emplace(l, 1);
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto p : lens) {
      int l = p.first;
      int k = p.second;
      s = (s + ((separate(a.at(i), l) % 998244353) * k) % 998244353) %
          998244353;
      s = (s +
           ((((separate(a.at(i), l - 1) % 998244353) * 10) % 998244353) * k) %
               998244353) %
          998244353;
    }
  }
  cout << s << endl;
  return 0;
}
