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