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