#include <bits/stdc++.h>
using namespace std;
int Set(int mask, int pos) { return mask = mask | (1 << pos); }
bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }
int n, arr[100005], tt[100005];
int cnt[100005], counter[100005], cs[100005];
long long p[30];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    int k = 0, temp = arr[i];
    while (temp) {
      int r = temp % 10;
      temp /= 10;
      k++;
      counter[k] += 1;
      cs[k] += r;
    }
    cnt[k]++;
    tt[i] = arr[i];
  }
  p[0] = 1;
  for (int i = 1; i < 20; i++) p[i] = (p[i - 1] * 10) % 998244353;
  long long ans = 0;
  for (int i = 1; i <= 10; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[j] == 0) continue;
      int t = arr[j] % 10;
      arr[j] /= 10;
      ans += ((((counter[i] - 1) * p[i + i - 1] * t) % 998244353 +
               ((cs[i] - t) * p[i + i - 2]) % 998244353)) %
             998244353;
      for (int k = i - 1; k >= 0; k--) {
        ans += (((cnt[k] * p[i + k - 1]) % 998244353 * 2) % 998244353 * t) %
               998244353;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int k = 0;
    long long res = 0;
    while (tt[i]) {
      res += (tt[i] % 10 * p[k]);
      k++;
      res += (tt[i] % 10 * p[k]);
      k++;
      tt[i] /= 10;
    }
    ans = (ans + res) % 998244353;
  }
  cout << ans % 998244353 << endl;
  return 0;
}
