#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 998244353;
string a[maxn];
int b[maxn][15];
map<int, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i][0] = a[i].size();
    int kk = b[i][0] - 1;
    for (int j = 1; j <= b[i][0]; j++) b[i][j] = a[i][kk] - '0', kk--;
    mp[b[i][0]]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int len = 1; len <= 10; len++) {
      int kk = 1, tmp = 0;
      for (int j = 1; j <= b[i][0]; j++) {
        (tmp += b[i][j] * kk) %= mod;
        if (j <= len)
          (kk *= 100) %= mod;
        else
          (kk *= 10) %= mod;
      }
      (ans += mp[len] * tmp) %= mod;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int len = 1; len <= 10; len++) {
      int kk = 10, tmp = 0;
      for (int j = 1; j <= b[i][0]; j++) {
        (tmp += b[i][j] * kk) %= mod;
        if (j < len)
          (kk *= 100) %= mod;
        else
          (kk *= 10) %= mod;
      }
      (ans += mp[len] * tmp) %= mod;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
