#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
long long n, a[100009], cnt[19];
int cnt_digits(int x) {
  int ret = 0;
  while (x) {
    ret++;
    x /= 10;
  }
  return ret;
}
vector<int> get_digits(int x) {
  vector<int> v;
  while (x) {
    int r = x % 10;
    v.push_back(r);
    x /= 10;
  }
  reverse(v.begin(), v.end());
  return v;
}
long long get_prod(vector<int> &v) {
  long long ret = 0;
  for (int i = 0; i < v.size(); i++) ret = ((ret * 10) % MOD + v[i]) % MOD;
  return ret;
}
long long mulmod(long long a, long long b) {
  long long res = 0;
  a = a % MOD;
  while (b) {
    if (b % 2 != 0) res = (res + a) % MOD;
    a = (a * 2) % MOD;
    b /= 2;
  }
  return res % MOD;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[cnt_digits(a[i])]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    vector<int> cur = get_digits(a[i]);
    int index = (int)cur.size() - 1, with = 1;
    while (index != 0) {
      cur.insert(cur.begin() + index, 0);
      index--;
      long long num = get_prod(cur);
      num = mulmod(num, cnt[with]);
      with++;
      ans += num;
      ans %= MOD;
    }
    long long num = get_prod(cur);
    for (int j = with; j <= 10; j++) ans = (ans + mulmod(num, cnt[j])) % MOD;
  }
  for (int i = 0; i < n; i++) {
    vector<int> cur = get_digits(a[i]);
    int index = (int)cur.size(), with = 1;
    while (index != 0) {
      cur.insert(cur.begin() + index, 0);
      index--;
      long long num = get_prod(cur);
      num = mulmod(num, cnt[with]);
      with++;
      ans += num;
      ans %= MOD;
    }
    long long num = get_prod(cur);
    for (int j = with; j <= 10; j++) ans = (ans + mulmod(num, cnt[j])) % MOD;
  }
  cout << ans;
  return 0;
}
