#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 998244353;
unsigned long long modExp(unsigned long long a, unsigned long long p,
                          unsigned long long m) {
  unsigned long long res = 1;
  a = a % m;
  while (p > 0) {
    if (p & 1) {
      res = ((res % m) * (a % m)) % m;
    }
    p >>= 1;
    a = (a % m * a % m) % m;
  }
  return res;
}
unsigned long long f(unsigned long long n, unsigned long long len,
                     vector<unsigned long long>& freq) {
  unsigned long long res = 0;
  unsigned long long l = min(len, (unsigned long long)to_string(n).length());
  int i;
  for (i = 1; i <= l; i++) {
    int digit = n % 10;
    res += freq[len] * digit *
           (modExp(10, 2 * i - 1, mod) + modExp(10, 2 * i - 2, mod));
    res %= mod;
    n /= 10;
  }
  i = 2 * i - 2;
  while (n > 0) {
    int digit = n % 10;
    res += 2 * freq[len] * digit * (modExp(10, i, mod));
    res %= mod;
    n /= 10;
    i++;
  }
  return res;
}
int main() {
  unsigned long long n;
  cin >> n;
  vector<unsigned long long> a(n);
  vector<unsigned long long> freq(11);
  int maxLen = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int len = to_string(a[i]).length();
    maxLen = max(maxLen, len);
    freq[len]++;
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int l = 1; l <= maxLen; l++) {
      ans += f(a[i], l, freq);
      ans %= mod;
    }
  }
  cout << ans;
  return 0;
}
