N = int(input()) A = sorted(list(map(int, input().split()))) x = 0 for a in A: x = 10*x + a print(x % 998244353)