#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long b, long long c) {
  long long t = 1;
  while (b) {
    if (b & 1) t = t * a % c;
    a = a * a % c;
    b >>= 1;
  }
  return t;
}
int test = 1;
const int maxn = 5 + 1e5;
const int maxm = 5 + 1e5;
int n;
long long ar[maxn];
int len[maxn];
int cnt[20];
long long sum[20];
int main() {
  while (test--) {
    scanf("%d", &n);
    int t;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &ar[i]);
      len[i] = 0;
      t = ar[i];
      while (t) {
        len[i]++;
        t /= 10;
      }
      cnt[len[i]]++;
    }
    for (int i = 1; i <= 9; i++) {
      sum[i] = sum[i - 1] + cnt[i];
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      long long tmp = 11;
      long long tmp2 = 2;
      t = ar[i];
      for (int j = 1; j <= len[i]; j++) {
        ans = (ans + t % 10 * tmp * (n - sum[j - 1])) % mod;
        ans = (ans + t % 10 * tmp2 * (sum[j - 1])) % mod;
        t /= 10;
        tmp = tmp * 100 % mod;
        tmp2 = tmp2 * 100 % mod;
      }
    }
    cout << ans % mod << endl;
  }
  return 0;
}
