N = int(input()) A = list(map(int,input().split())) MOD = 998244353 A.sort(key=lambda x:str(x)) ans = int(''.join(map(str,A))) % MOD print(ans)