#include <bits/stdc++.h>
using namespace std;
long long n, a[100021], cnt[100021];
long long Q(long long x) {
  long long ans = 0;
  while (x) {
    ans++;
    x /= 10;
  }
  return ans;
}
long long make1(long long x, long long y) {
  long long bs = 10, ans = 0;
  for (long long i = 1; i <= y; i++) {
    ans += x % 10 * bs;
    ans %= 998244353ll;
    x /= 10;
    if (i != y)
      bs = bs * 100 % 998244353ll;
    else
      bs = bs * 10 % 998244353ll;
  }
  while (x) {
    ans += x % 10 * bs;
    ans %= 998244353ll;
    x /= 10;
    bs = bs * 10 % 998244353ll;
  }
  return ans;
}
long long make2(long long x, long long y) {
  long long bs = 1, ans = 0;
  for (long long i = 1; i <= y; i++) {
    ans += x % 10 * bs;
    ans %= 998244353ll;
    x /= 10;
    bs = bs * 100 % 998244353ll;
  }
  while (x) {
    ans += x % 10 * bs;
    ans %= 998244353ll;
    x /= 10;
    bs = bs * 10 % 998244353ll;
  }
  return ans;
}
int main() {
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d", a + i);
    cnt[Q(a[i])]++;
  }
  long long ans = 0, x;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= 10; j++) {
      long long p = make1(a[i], j);
      long long q = make2(a[i], j);
      ans = (ans + (p + q) * cnt[j]) % 998244353ll;
    }
  }
  printf("%I64d", ans);
  return 0;
}
