#include <bits/stdc++.h>
using namespace std;
const long long SZ = 1e5 + 7;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const long long MOD = 998244353;
long long modadd(long long a, long long b, long long m = MOD) {
  a = a % m;
  b = b % m;
  return (((a + b) % m) + m) % m;
}
long long modsub(long long a, long long b, long long m = mod) {
  a = a % m;
  b = b % m;
  return (((a - b) % m) + m) % m;
}
long long modmul(long long a, long long b, long long m = MOD) {
  a = a % m;
  b = b % m;
  return (((a * b) % m) + m) % m;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> fre(11);
  for (long long i = 0; i < n; ++i) {
    long long cnt = 0;
    long long temp = a[i];
    while (temp) {
      cnt++;
      temp /= 10;
    }
    fre[cnt]++;
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    vector<long long> val;
    long long temp = a[i];
    while (temp) {
      val.push_back(temp % 10);
      temp /= 10;
    }
    for (long long d = 1; d < 11; ++d) {
      long long len = max((long long)val.size(), d);
      long long nxt = 1;
      long long nw = 0;
      for (long long j = 0; j < len; ++j) {
        if (j < d) {
          nxt = modmul(nxt, 10);
        }
        if (j < (long long)val.size()) {
          nw = modadd(nw, modmul(val[j], nxt));
          nxt = modmul(nxt, 10);
        }
      }
      ans = modadd(ans, modmul(nw, fre[d]));
      nxt = 1;
      nw = 0;
      for (long long j = 0; j < len; ++j) {
        if (j < (long long)val.size()) {
          nw = modadd(nw, modmul(val[j], nxt));
          nxt = modmul(nxt, 10);
        }
        if (j < d) {
          nxt = modmul(nxt, 10);
        }
      }
      ans = modadd(ans, modmul(nw, fre[d]));
    }
  }
  cout << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
