#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int sum(int a, int b) { return (int)((1ll * a + b) % mod); }
inline int sub(int a, int b) { return (int)((a -= b) % mod < 0) ? a + mod : a; }
inline int mul(int a, int b) { return (int)((1ll * a * b) % mod); }
int pow(int x, int a) {
  if (a == 0) return 1;
  int ret = pow(x, a / 2);
  ret = mul(ret, ret);
  if (a & 1) ret = mul(x, ret);
  return ret;
}
int sums[11][10], cnt[11];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    int ret[10];
    int j = 0, cur = a[i];
    while (cur) {
      ret[j] = cur % 10;
      j++;
      cur /= 10;
    }
    for (int k = 0; k < 10; ++k) sums[j][k] = sum(sums[j][k], ret[k]);
    cnt[j]++;
  }
  int ans = 0;
  for (int i = 0; i < 11; ++i)
    for (int j = 0; j < 11; ++j) {
      int m = 1, ci = 0, cj = 0;
      int ret = 0;
      while (ci < i || cj < j) {
        if (cj < j) {
          ret = sum(ret, mul(mul(m, sums[j][cj]), cnt[i]));
          m = mul(m, 10);
          cj++;
        }
        if (ci < i) {
          ret = sum(ret, mul(mul(m, sums[i][ci]), cnt[j]));
          m = mul(m, 10);
          ci++;
        }
      }
      ans = sum(ans, ret);
    }
  cout << ans << endl;
}
