#include <bits/stdc++.h>
using namespace std;
long long arr[300005], brr[300005], crr[300005], wei[300005], p[300005],
    cnt[300005];
long long mod = 998244353;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  p[0] = 1;
  for (int i = 1; i <= 15; i++) p[i] = p[i - 1] * 10 % mod;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    crr[i] = arr[i];
    int num = 0;
    while (crr[i]) {
      crr[i] /= 10;
      num++;
    }
    cnt[num]++;
    wei[i] = num;
  }
  for (int i = 1; i <= n; i++) {
    long long b = arr[i], pos = 0;
    while (b) {
      pos++;
      long long c = b % 10;
      b /= 10;
      for (int j = 1; j <= 9; j++) {
        if (pos <= j)
          ans = (ans + c * p[2 * pos - 1] % mod * cnt[j] % mod) % mod;
        else
          ans = (ans + c * p[pos + j - 1] % mod * cnt[j] % mod) % mod;
        if (pos <= j)
          ans = (ans + c * p[2 * (pos - 1)] % mod * cnt[j] % mod) % mod;
        else
          ans = (ans + c * p[pos + j - 1] % mod * cnt[j] % mod) % mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
