N = int(input()) A = list(map(str,input().split())) A.sort() ans = 0 mod = 998244353 for i in range(N): d = len(A[i]) ans *= pow(10,d,mod) ans %= mod ans += int(A[i]) ans %= mod print(ans)