#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  const long long int rem = 998244353;
  ;
  long long int n;
  cin >> n;
  long long int a[n], b[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  long long int mx = 1;
  for (long long int i = 0; i < n; i++) mx = max(mx, a[i]);
  long long int temp = mx;
  long long int dig = 0;
  while (temp > 0) {
    dig++;
    temp = temp / 10;
  }
  long long int wsum[dig];
  for (int i = 0; i < dig; i++) wsum[i] = 0;
  for (long long int i = 0; i < dig; i++) {
    for (long long int j = 0; j < n; j++) {
      wsum[i] = (wsum[i] + b[j]) % rem;
      b[j] = b[j] / 10;
    }
  }
  long long int pow = 1;
  long long int sum1 = 0;
  long long int sum2 = 0;
  long long int carry = 0;
  long long int ans = 0;
  long long int curr_w = n;
  for (long long int i = 0; i < dig; i++) {
    sum1 = sum2 = 0;
    for (long long int j = 0; j < n; j++) {
      if (a[j] != -1) {
        if (a[j] == 0) {
          sum1 = (sum1 + 2 * wsum[i]) % rem;
          a[j] = -1;
          curr_w--;
        } else {
          sum2 = (sum2 + (a[j] % 10)) % rem;
          a[j] = a[j] / 10;
        }
      }
    }
    long long int temp = sum1 + curr_w * sum2 + carry;
    carry = temp / 10;
    temp = temp % 10;
    ans = (ans + ((temp * pow) % rem)) % rem;
    pow = (pow * 10) % rem;
    temp = curr_w * sum2 + carry;
    carry = temp / 10;
    temp = temp % 10;
    ans = (ans + ((temp * pow) % rem)) % rem;
    pow = (pow * 10) % rem;
  }
  ans = (ans + ((carry * pow) % rem)) % rem;
  cout << ans;
}
