#include <bits/stdc++.h>
const int N = 100000 + 100;
const int mod = 998244353;
const long long inf = (1 << 31) - 1;
using namespace std;
int n, cnt[N];
long long a[N], ans = 0, p10[30];
void init(long long x, int i) {
  int ans = 0;
  while (x) {
    ans++;
    x /= 10;
  }
  cnt[ans]++;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  p10[1] = 1;
  for (int i = 2; i < 30; i++) p10[i] = (p10[i - 1] * 10) % mod;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    init(a[i], i);
  }
  for (int i = 1; i <= n; i++) {
    long long b = a[i];
    int pos = 0;
    while (b) {
      long long c = b % 10;
      b = b / 10;
      pos++;
      for (int j = 1; j <= 10; j++) {
        if (j >= pos) {
          ans += c * cnt[j] * p10[pos * 2];
          ans += c * cnt[j] * p10[pos * 2 - 1];
        } else {
          ans += 2 * c * cnt[j] * p10[pos + j];
        }
      }
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}
