#include <bits/stdc++.h>
using namespace std;
template <class T, class T1>
int chkmin(T &x, const T1 &y) {
  return x > y ? x = y, 1 : 0;
}
template <class T, class T1>
int chkmax(T &x, const T1 &y) {
  return x < y ? x = y, 1 : 0;
}
const int MAXN = (1 << 20);
const int mod = 998244353;
int n;
string a[MAXN];
void read() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
}
int sum[22][22];
int cnt[22];
int pw10[22];
void solve() {
  pw10[0] = 1;
  for (int i = 1; i <= 20; i++) pw10[i] = pw10[i - 1] * 10ll % mod;
  for (int i = 0; i < n; i++) {
    int l1 = a[i].size();
    cnt[l1]++;
    reverse(a[i].begin(), a[i].end());
    for (int j = 0; j < ((int)a[i].size()); j++)
      sum[l1][j] = (sum[l1][j] + a[i][j] - '0') % mod;
  }
  int ans = 0;
  for (int l1 = 1; l1 <= 20; l1++)
    for (int l2 = 1; l2 <= 20; l2++)
      for (int p = 0; p < l1; p++) {
        int a_p = p + min(p + 1, l2);
        ans = (ans + ((pw10[a_p] * 1ll * sum[l1][p] % mod) * 1ll * cnt[l2])) %
              mod;
      }
  for (int l1 = 1; l1 <= 20; l1++)
    for (int l2 = 1; l2 <= 20; l2++)
      for (int p = 0; p < l1; p++) {
        int a_p = p + min(p, l2);
        ans = (ans + ((pw10[a_p] * 1ll * sum[l1][p] % mod) * 1ll * cnt[l2])) %
              mod;
      }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
