#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},
                            {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cerr << endl; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
    cerr << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug& operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug& operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
long long gcd(long long a, long long b) {
  if (b) return gcd(b, a % b);
  return a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long n, x, P[50];
vector<long long> vec[1 << 17];
long long cnt[1 << 17], ans;
const long long mod = 998244353;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x;
    while (x) {
      vec[i].push_back(x % 10);
      x /= 10;
    }
    cnt[(long long)((vec[i]).size())]++;
  }
  P[0] = 1;
  for (long long i = 1; i <= 30; i++) {
    P[i] = (P[i - 1] * 10) % mod;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long len = 1; len <= 10; len++) {
      long long c = cnt[len];
      long long x = 0;
      vector<char> kek;
      long long p = (long long)((vec[i]).size());
      long long q = len;
      if (p >= q) {
        for (long long j = 1; j <= p - q + 1; j++) kek.push_back('a');
        kek.push_back('b');
        for (long long j = 1; j < q; j++) {
          kek.push_back('a');
          kek.push_back('b');
        }
      } else {
        for (long long j = 1; j <= q - p; j++) {
          kek.push_back('b');
        }
        for (long long j = 1; j <= p; j++) {
          kek.push_back('a');
          kek.push_back('b');
        }
      }
      reverse(kek.begin(), kek.end());
      long long cnt = 0;
      for (long long j = 0; j < (long long)((kek).size()); j++) {
        if (kek[j] == 'a') {
          ans += ((vec[i][cnt++] * P[j]) % mod) * c;
          ans %= mod;
        }
      }
    }
    for (long long len = 1; len <= 10; len++) {
      long long c = cnt[len];
      long long x = 0;
      vector<char> kek;
      long long q = (long long)((vec[i]).size());
      long long p = len;
      if (p >= q) {
        for (long long j = 1; j <= p - q + 1; j++) kek.push_back('a');
        kek.push_back('b');
        for (long long j = 1; j < q; j++) {
          kek.push_back('a');
          kek.push_back('b');
        }
      } else {
        for (long long j = 1; j <= q - p; j++) {
          kek.push_back('b');
        }
        for (long long j = 1; j <= p; j++) {
          kek.push_back('a');
          kek.push_back('b');
        }
      }
      reverse(kek.begin(), kek.end());
      long long cnt = 0;
      for (long long j = 0; j < (long long)((kek).size()); j++) {
        if (kek[j] == 'b') {
          ans += ((vec[i][cnt] * P[j]) % mod) * c;
          ans %= mod;
          cnt++;
        }
      }
    }
  }
  return cout << ans, 0;
  return 0;
}
