#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long data[(int)1e5 + 5];
int len[15];
int clen(long long num) {
  int cnt = 0;
  while (num) {
    cnt++;
    num /= 10;
  }
  return cnt;
}
long long cont(long long num, int cnt, int l) {
  long long ans = 0, n = cnt, p = 1, Num = num;
  int L = l;
  while (L--) {
    long long e = Num % 10;
    ans += ((cnt % mod) * (p * e) % mod + (cnt % mod) * (10 * p * e) % mod);
    p = ((p % mod) * 100) % mod;
    Num = Num / 10;
  }
  while (Num) {
    long long e = Num % 10;
    ans += cnt * (2 * p * e) % mod;
    Num /= 10;
    p = (p * 10) % mod;
  }
  return ans % mod;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> data[i];
    len[clen(data[i])]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int l = 1; l <= 10; l++) {
      if (len[l] == 0) continue;
      ans = (ans + cont(data[i], len[l], l)) % mod;
    }
  }
  cout << ans << endl;
}
