/* In the name of *Allah* *
 *   Thank You *Parsa*    */
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<ios>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<numeric>
using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;

const int inf_int = 1 << 30;
const ll inf_longlong = 1LL << 62;
const int MOD = 998244353;

const int N = 2e5 + 5, M = 10 + 5;
int n, a[N];
int cnt[M], pow10[M], ans, suf[M];

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}
int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

void init() {
	pow10[0] = 1;
	for (int i = 1; i < M; i++) pow10[i] = mul(pow10[i - 1], 10);
}

void read_input() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
}

void solve() {
	for (int i = 0; i < n; i++) {
		int m = a[i], log10 = 0;
		while (m)
			log10++, m /= 10;
		cnt[log10]++;
	}
	for (int i = M - 2; i >= 0; i--) suf[i] = suf[i + 1] + cnt[i];


	for (int i = 0; i < n; i++) {
		int m = a[i], k = 1;
		while (m) {
			int tmp = ans;

			for (int j = k; j < k + k - 1; j++) {
				ans = add(ans, mul(m % 10, mul(pow10[j - 1], cnt[j - k])));
			}
			ans = add(ans, mul(m % 10, mul(pow10[k + k - 2], suf[k - 1])));

			for (int j = k; j < k + k; j++) {
				ans = add(ans, mul(m % 10, mul(pow10[j - 1], cnt[j - k])));
			}
			ans = add(ans, mul(m % 10, mul(pow10[k + k - 1], suf[k])));

			m /= 10;
			k++;
		}

	}
}

void write_output() {
	cout << ans << '\n';
}

int main() {
	ios:: sync_with_stdio(false), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	init();

	int test_cases = 1; //cin >> test_cases;
	while (test_cases--) {
		read_input(), solve(), write_output();
	}
	return 0;
}
// Thanks *Allah*