#include <bits/stdc++.h>
using namespace std;
long long cd(long long a, long long b) {
  if (a == 0)
    return b;
  else if (b == 0)
    return a;
  else
    return cd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n + 5];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long d[11][11] = {0}, t, c = 0, tem, che[11] = {0};
  for (int i = 0; i < n; i++) {
    c = 0;
    t = log10(a[i]) + 1;
    tem = a[i];
    che[t]++;
    while (a[i] > 0) {
      d[t][c] += a[i] % 10;
      a[i] = a[i] / 10;
      c++;
    }
    a[i] = tem;
  }
  for (int i = 0; i < 11; i++) {
    for (int j = 0; j < 11; j++) d[i][j] = d[i][j] % 998244353;
  }
  long long ans = 0, cc, tt;
  for (int i = 0; i < n; i++) {
    tem = a[i];
    for (int j = 1; j < 11; j++) {
      a[i] = tem;
      long long av1 = log10(a[i]) + 1;
      c = 1;
      cc = 0;
      tt = j;
      if (che[j] != 0) {
        while (av1 > 0 && tt > 0) {
          ans += c * d[j][cc];
          ans = ans % 998244353;
          c = c * 10;
          c = c % 998244353;
          ans += ((c * (a[i] % 10)) % 998244353) * che[j];
          a[i] = a[i] / 10;
          ans = ans % 998244353;
          c = c * 10;
          c = c % 998244353;
          cc++;
          av1--;
          tt--;
        }
        while (av1 > 0) {
          ans += ((c * (a[i] % 10)) % 998244353) * che[j];
          ans = ans % 998244353;
          a[i] = a[i] / 10;
          c = c * 10;
          c = c % 998244353;
          av1--;
        }
        while (tt > 0) {
          ans += c * d[j][cc];
          ans = ans % 998244353;
          c = c * 10;
          c = c % 998244353;
          cc++;
          tt--;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
