#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
int main() {
  int n;
  cin >> n;
  vector<string> a(n);
  int sz[11] = {0};
  for (string& s : a) {
    cin >> s;
    reverse(s.begin(), s.end());
    sz[s.size()]++;
  }
  long long pows[30] = {1};
  for (int i = 1; i < 30; ++i) {
    pows[i] = pows[i - 1] * 10 % mod;
  }
  long long ans = 0;
  for (string& s : a) {
    for (int i = 0; i < s.size(); ++i) {
      for (int j = 1; j <= 10; ++j) {
        (ans += (pows[min(i * 2, i + j)]) * sz[j] * (s[i] - '0')) %= mod;
        (ans += (pows[min(i * 2 + 1, i + j)] * sz[j] * (s[i] - '0'))) %= mod;
      }
    }
  }
  cout << ans << endl;
}
