N = int(input()) A = sorted(list(input().split())) ans = 0 MOD = 998244353 for i in range(N): ans = ans*10**len(A[i])+int(A[i]) ans %= MOD print(ans)