n = int(input()) A = list(map(int, input().split())) A.sort() x = 0 for i in range(n): A[i] = 10 * x + A[i] x = A[i] print(A[-1] % 998244353)