#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897923846;
const long long int MOD = 1000000007;
const long long int N = 998244353;
long long int power(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % N;
    x = x * x % N;
    n >>= 1;
  }
  return res;
}
long long int modinverse(long long int a) { return power(a, MOD - 2); }
long long int count(long long int num) {
  long long int dig = 0;
  long long int temp = num;
  while (temp) {
    dig++;
    temp /= 10;
  }
  return dig;
}
long long int doIt(long long int num) {
  long long int dig = 0;
  long long int temp = num;
  while (temp) {
    dig++;
    temp /= 10;
  }
  temp = num;
  long long int pow_of_ten = 1;
  long long int val = 0;
  while (temp) {
    long long int curr = temp % 10;
    val += (pow_of_ten * curr) % N;
    val %= N;
    pow_of_ten *= 10;
    pow_of_ten %= N;
    val += (pow_of_ten * curr) % N;
    val %= N;
    pow_of_ten *= 10;
    pow_of_ten %= N;
    temp /= 10;
  }
  return val;
}
long long int doIt2(long long int num, long long int diff) {
  long long int dig = 0;
  long long int temp = num;
  while (temp) {
    dig++;
    temp /= 10;
  }
  temp = num;
  long long int pow_of_ten = 1;
  long long int val = 0;
  long long int k = 0;
  while (count(temp) > diff) {
    long long int curr = temp % 10;
    val += (pow_of_ten * curr) % N;
    k++;
    val %= N;
    pow_of_ten *= 10;
    pow_of_ten %= N;
    val += (pow_of_ten * curr) % N;
    k++;
    val %= N;
    pow_of_ten *= 10;
    pow_of_ten %= N;
    temp /= 10;
  }
  val += (2 * pow_of_ten * temp) % N;
  val %= N;
  return val;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  vector<vector<long long int> > digits(11);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    long long int dig = 0;
    long long int temp = a[i];
    while (temp) {
      dig++;
      temp /= 10;
    }
    digits[dig].push_back(a[i]);
  }
  long long int ans = 0;
  for (long long int i = 0; i < 11; i++) {
    for (long long int j = 0; j < digits[i].size(); j++) {
      ans += (((long long int)digits[i].size()) * doIt(digits[i][j])) % N;
      ans %= N;
    }
  }
  for (long long int i = 0; i < 10; i++) {
    for (long long int k = 0; k < digits[i].size(); k++) {
      for (long long int j = 0; j < 10; j++) {
        if (i > j) {
          ans += (digits[j].size() * doIt2(digits[i][k], (i - j))) % N;
          ans %= N;
        } else if (j > i) {
          ans += (digits[j].size() * doIt(digits[i][k])) % N;
          ans %= N;
        }
      }
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int test = 1;
  while (test--) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
