#include <bits/stdc++.h>
const double pi = acos(-1.0);
const int maxn = (1000 + 10);
const int inf = 0x3f3f3f3f;
const unsigned long long mod = 998244353;
using namespace std;
unsigned long long z[100001][20], y[100001][20];
unsigned long long weishu[110], ssum[100];
unsigned long long quick_multi(unsigned long long a, unsigned long long b,
                               unsigned long long m) {
  unsigned long long ans = 0;
  while (b) {
    if (b % 2 == 1) ans = (ans + a) % m;
    a = (a * 2) % m;
    b /= 2;
  }
  return ans % mod;
}
int main() {
  ios::sync_with_stdio(false);
  unsigned long long n;
  cin >> n;
  memset(ssum, 0, sizeof(ssum));
  memset(z, 0, sizeof(z));
  memset(y, 0, sizeof(y));
  memset(weishu, 0, sizeof(weishu));
  for (unsigned long long i = 1; i <= n; i++) {
    unsigned long long x;
    cin >> x;
    unsigned long long temp = x, s = 0;
    while (temp) {
      s += 1;
      weishu[s] = temp % 10;
      temp /= 10;
    }
    ssum[s] += 1;
    ssum[s] %= mod;
    for (unsigned long long t = 1; t <= s; t++) {
      unsigned long long ss = 10, now = 0;
      for (unsigned long long j = 1; j <= t; j++) {
        now += ss * weishu[j] % mod;
        now %= mod;
        if (j != t)
          for (unsigned long long k = 1; k <= 2; k++) ss *= 10;
        else
          ss *= 10;
      }
      for (unsigned long long j = t + 1; j <= s; j++) {
        now += ss * weishu[j] % mod;
        now %= mod;
        ss *= 10;
      }
      if (t == s)
        for (unsigned long long r = s; r <= 10; r++) z[i][r] = now;
      else
        z[i][t] = now;
    }
    if (s == 1)
      for (unsigned long long r = 1; r <= 10; r++) y[i][r] = weishu[1];
    for (unsigned long long t = 2; t <= s; t++) {
      unsigned long long ss = 100, now = weishu[1];
      for (unsigned long long j = 2; j <= t; j++) {
        now += ss * weishu[j] % mod;
        now %= mod;
        if (j != t)
          for (unsigned long long k = 1; k <= 2; k++) ss *= 10;
        else
          ss *= 10;
      }
      for (unsigned long long j = t + 1; j <= s; j++) {
        now += ss * weishu[j] % mod;
        now %= mod;
        ss *= 10;
      }
      if (t == s)
        for (unsigned long long r = s; r <= 11; r++) y[i][r - 1] = now;
      else
        y[i][t - 1] = now;
    }
  }
  unsigned long long ans = 0;
  for (unsigned long long i = 1; i <= n; i++)
    for (unsigned long long j = 1; j <= 10; j++) {
      ans = (ans + quick_multi(z[i][j] % mod, ssum[j] % mod, mod)) % mod;
      ans = (ans + quick_multi(y[i][j] % mod, ssum[j] % mod, mod)) % mod;
    }
  cout << ans;
  return 0;
}
