#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const vector<int> dx = {0,0,1,-1};
const vector<int> dy = {1,-1,0,0};
const ll INF = 1e18;
const ll inf = 1e8;
const ll MOD = 998244353;


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(),a.end());

    ll x = 0;
    for(int i = 0; i < n; i++) {
        x = 10*x + a[i];
        x %= MOD;
    }

    cout << x << endl;
}