N = int(input()) A = sorted(list(map(int, input().split()))) MOD = 998244353 X = 0 for i in range(N): X = 10*X+A[i] X %= MOD print(X)