#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int MAX = 1e5 + 5;
string str[MAX];
int N, mp[15];
long long ans, p[30];
void solve(string s) {
  reverse((s).begin(), (s).end());
  for (int k = (1); k <= (10); k++) {
    long long aux = 0;
    int j = 0, c = 1;
    for (int i = (0); i < (s.size()); i++) {
      aux = (aux + (s[i] - '0') * p[j]) % mod;
      if (c <= k) j++;
      j++;
      c++;
    }
    ans = (ans + aux * mp[k]) % mod;
  }
  for (int k = (1); k <= (10); k++) {
    long long aux = 0;
    int j = 1, c = 1;
    for (int i = (0); i < (s.size()); i++) {
      aux = (aux + (s[i] - '0') * p[j]) % mod;
      if (c < k) j++;
      j++;
      c++;
    }
    ans = (ans + aux * mp[k]) % mod;
  }
}
int main(int argc, char** argv) {
  cin >> N;
  p[0] = 1;
  for (int i = (1); i < (26); i++) p[i] = (p[i - 1] * 10) % mod;
  for (int i = (0); i < (N); i++) {
    cin >> str[i];
    mp[str[i].size()]++;
  }
  for (int i = (0); i < (N); i++) solve(str[i]);
  cout << ans << "\n";
  return 0;
}
