#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
const long long mod = 998244353;
const int N = 2e5 + 100;
int a[N];
int len[N], tlen[N];
int cal(int x) {
  int ret = 0;
  while (x) {
    ++ret;
    x /= 10;
  }
  return ret;
}
long long ans = 0;
void solve1(int x) {
  vector<int> vc;
  int v = a[x];
  while (v) {
    vc.push_back(v % 10);
    v /= 10;
  }
  for (int g = 1; g <= 10; ++g) {
    int f = g - 1;
    long long base = 10;
    long long tv = 0;
    for (int j = 0; j < vc.size(); ++j) {
      tv = (tv + vc[j] * base) % mod;
      base = base * 10 % mod;
      if (f) {
        --f;
        base = base * 10 % mod;
      }
    }
    ans = (ans + tv * tlen[g]) % mod;
  }
  vc.clear();
}
void solve2(int x) {
  vector<int> vc;
  int v = a[x];
  while (v) {
    vc.push_back(v % 10);
    v /= 10;
  }
  for (int g = 1; g <= 10; ++g) {
    int f = g;
    long long base = 1;
    long long tv = 0;
    for (int j = 0; j < vc.size(); ++j) {
      tv = (tv + vc[j] * base) % mod;
      base = base * 10 % mod;
      if (f) {
        --f;
        base = base * 10 % mod;
      }
    }
    ans = (ans + tv * tlen[g]) % mod;
  }
  vc.clear();
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    len[i] = cal(a[i]);
    ++tlen[len[i]];
  }
  for (int i = 1; i <= n; ++i) {
    solve1(i);
    solve2(i);
  }
  cout << ans << endl;
  return 0;
}
