#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
int n;
int a[100001];
long long l[20];
long long p[20];
const int mod = 998244353;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  p[0] = 1;
  for (int i = 1; i <= 20; i++) {
    p[i] = (p[i - 1] * 10) % mod;
  }
  for (int i = 0; i < n; i++) {
    string y = to_string(a[i]);
    l[y.size()]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 10; j++) {
      string t = to_string(a[i]);
      int s = t.size();
      int pos = 0;
      for (int k = 1; k <= min(s, j); k++, pos += 2)
        ans = (ans + p[pos] * (t[s - k] - '0') * l[j]) % mod;
      for (int k = j + 1; k <= s; k++, pos++) {
        ans = (ans + p[pos] * (t[s - k] - '0') * l[j]) % mod;
      }
      pos = 1;
      for (int k = 1; k <= min(s, j); k++, pos += 2)
        ans = (ans + p[pos] * (t[s - k] - '0') * l[j]) % mod;
      pos--;
      for (int k = j + 1; k <= s; k++, pos++) {
        ans = (ans + p[pos] * (t[s - k] - '0') * l[j]) % mod;
      }
    }
  }
  cout << ans;
  return 0;
}
