#include <bits/stdc++.h>
using namespace std;
int read(int &x) { return scanf("%d", &x); }
int read(int &x, int &y) { return scanf("%d%d", &x, &y); }
int read(long long &x) { return scanf("%lld", &x); }
char buff[1000010];
int read(string &s) {
  int r = scanf("%s", buff);
  s = buff;
  return r;
}
long long len(long long d) {
  int r = 0;
  while (d > 0) d /= 10, r++;
  return r;
}
long long computeIfA(long long a, int lenB) {
  long long t = 0;
  long long p = 1;
  while (a > 0 || lenB > 0) {
    if (lenB > 0) {
      lenB--;
      p *= 10;
    }
    t += p * (a % 10);
    p *= 10;
    a /= 10;
    p %= 998244353;
  }
  return t % 998244353;
}
long long computeIfB(long long b, int lenA) {
  long long t = 0;
  long long p = 1;
  while (b > 0 || lenA > 0) {
    t += p * (b % 10);
    p *= 10;
    b /= 10;
    if (lenA > 0) {
      lenA--;
      p *= 10;
    }
    p %= 998244353;
  }
  return t % 998244353;
}
int main() {
  int N;
  read(N);
  vector<long long> A(N);
  for (long long &n : A) read(n);
  vector<long long> F(15);
  for (long long n : A) F[len(n)]++;
  long long ans = 0;
  for (long long n : A) {
    for (int i = 0; i < F.size(); ++i) {
      if (F[i] == 0) continue;
      ans += (F[i] * (computeIfA(n, i) + computeIfB(n, i))) % 998244353;
    }
    ans %= 998244353;
  }
  cout << ans << endl;
}
