#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long hell = 998244353;
long long f(long long a) {
  long long p = 0;
  while (a > 0) {
    a /= 10;
    p++;
  }
  return p - 1;
}
signed solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  vector<long long> d(10);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    d[f(v[i])]++;
  }
  vector<long long> sm(20);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) {
      long long nbr = d[j];
      long long a = v[i];
      long long cnt1 = 0;
      long long cnt2 = 1;
      long long p = 0;
      while (a != 0) {
        long long l = a % 10;
        a /= 10;
        sm[cnt1] += (nbr * l);
        sm[cnt1] %= hell;
        sm[cnt2] += (nbr * l);
        sm[cnt2] %= hell;
        cnt1++;
        if (p <= j) cnt1++;
        cnt2++;
        if (p < j) cnt2++;
        p++;
      }
    }
  }
  long long sum = 0;
  long long f = 1;
  for (long long i = 0; i < 20; i++) {
    sum += (f * sm[i]) % hell;
    sum %= hell;
    f *= 10;
    f %= hell;
  }
  cout << sum << endl;
  return 0;
}
signed main() {
  long long t = 1;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  while (t--) {
    solve();
  }
  return 0;
}
