#include <bits/stdc++.h>
using namespace std;
const long long int lim = 100001;
long long int powe(long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans * a;
    }
    a = a * a;
    b = b >> 1;
  }
  return ans;
}
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b & 1) {
      ans = ((ans % 998244353) * (a % 998244353)) % 998244353;
    }
    a = ((a % 998244353) * (a % 998244353)) % 998244353;
    b = b >> 1;
  }
  return ans % 998244353;
}
vector<long long int> split(long long int n) {
  vector<long long int> ans;
  while (n > 0) {
    ans.push_back(n % 10);
    n = n / 10;
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  vector<vector<long long int> > numbers;
  map<long long int, long long int> lencount;
  map<long long int, set<long long int> > make_pair;
  for (int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    auto in = split(temp);
    numbers.push_back(in);
    lencount[in.size()]++;
  }
  map<long long int, long long int> powerkrenge;
  for (auto i : numbers) {
    for (int otherlen = 1; otherlen <= 10; otherlen++) {
      if (i.size() < otherlen) {
        for (int j = 0; j < i.size(); j++) {
          powerkrenge[2 * j + 1] += lencount[otherlen] * i[j];
          powerkrenge[2 * j + 1] %= 998244353;
        }
      } else {
        for (int j = 0; j < otherlen; j++) {
          powerkrenge[2 * j + 1] += lencount[otherlen] * i[j];
          powerkrenge[2 * j + 1] %= 998244353;
        }
        for (int j = otherlen; j < i.size(); j++) {
          powerkrenge[2 * otherlen + j - otherlen] += lencount[otherlen] * i[j];
          powerkrenge[2 * otherlen + j - otherlen] %= 998244353;
        }
      }
    }
    for (int otherlen = 1; otherlen <= 10; otherlen++) {
      if (i.size() < otherlen) {
        for (int j = 0; j < i.size(); j++) {
          powerkrenge[2 * j] += lencount[otherlen] * i[j];
          powerkrenge[2 * j] %= 998244353;
        }
      } else {
        for (int j = 0; j < otherlen; j++) {
          powerkrenge[2 * j] += lencount[otherlen] * i[j];
          powerkrenge[2 * j] %= 998244353;
        }
        for (int j = otherlen; j < i.size(); j++) {
          powerkrenge[2 * otherlen + j - otherlen] += lencount[otherlen] * i[j];
          powerkrenge[2 * otherlen + j - otherlen] %= 998244353;
        }
      }
    }
  }
  long long int ans = 0;
  for (auto i : powerkrenge) {
    ans = (ans + (((i.second) % 998244353) * power(10, i.first)) % 998244353) %
          998244353;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t > 0) {
    string s1, s2;
    solve();
    t--;
  }
}
