#include <bits/stdc++.h>
using namespace std;
int mod = 998244353;
vector<string> nums;
vector<int> lenCount(20, 0);
vector<vector<int> > indexSum(20, vector<int>(20));
unsigned long long f(string a, int len) {
  string b = "";
  for (int i = 0; i < len; i++) b += '?';
  int atA = a.size() - 1, atB = b.size() - 1;
  string c = "";
  while (atA >= 0 || atB >= 0) {
    if (atB >= 0) {
      c += b[atB];
      atB--;
    }
    if (atA >= 0) {
      c += a[atA];
      atA--;
    }
  }
  reverse(c.begin(), c.end());
  unsigned long long ans = 0;
  unsigned long long pow = 1;
  int idx = 0;
  for (int i = c.size() - 1; i >= 0; i--) {
    if (c[i] == '?') {
      ans = (ans + indexSum[len][idx] * pow);
      idx++;
    } else {
      ans = ans + ((c[i] - '0') * pow * lenCount[len]);
    }
    pow *= 10;
    pow = pow % mod;
    ans = ans % mod;
  }
  ans = ans % mod;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string in;
    cin >> in;
    nums.push_back(in);
  }
  for (int i = 0; i < n; i++) {
    lenCount[nums[i].size()]++;
    for (int j = 0; j < (int)nums[i].size(); j++) {
      indexSum[nums[i].size()][j] += (nums[i][nums[i].size() - 1 - j] - '0');
    }
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 12; j++) {
      if (lenCount[j] != 0) {
        ans = (ans + f(nums[i], j)) % mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
