N = int(input()) A = list(map(str, input().split())) A.sort() x = 0 for a in A: x += int(a) print(x % 998244353)