#include <bits/stdc++.h>
using namespace std;
int cnt[15];
string a[100009];
const long long mod = 998244353LL;
int main() {
  int i, len1, len2, n, j;
  long long p, sum, val;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    reverse(a[i].begin(), a[i].end());
    cnt[a[i].size()]++;
  }
  for (i = 1, val = 0; i <= n; i++) {
    len2 = a[i].size();
    for (len1 = 1; len1 <= 10; len1++) {
      sum = 0;
      if (len1 < len2) {
        for (j = 0, p = 1; j < len1; j++) {
          sum += p * (a[i][j] - 48);
          p = (p * 10LL) % mod;
          sum += p * (a[i][j] - 48);
          p = (p * 10LL) % mod;
        }
        for (j = len1; j < len2; j++) {
          sum += p * (a[i][j] - 48);
          sum += p * (a[i][j] - 48);
          p = (p * 10LL) % mod;
        }
      } else {
        for (j = 0, p = 1; j < len2; j++) {
          sum += p * (a[i][j] - 48);
          p = (p * 10LL) % mod;
          sum += p * (a[i][j] - 48);
          p = (p * 10LL) % mod;
        }
      }
      val += (sum % mod) * cnt[len1];
      val %= mod;
    }
  }
  cout << val << "\n";
  return 0;
}
