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