## https://yukicoder.me/problems/no/1612 from functools import cmp_to_key MOD = 998244353 def cmp_str(a, b): a1 = a + b a2 = b + a if a1 < a2: return -1 elif a1 > a2: return 1 else: return 0 def main(): N = int(input()) A = input().split() A = list(sorted(A, key=cmp_to_key(cmp_str))) answer_str = "".join(A) answer = 0 for a in answer_str: answer *= 10 answer %= MOD answer += int(a) answer %= MOD print(answer) if __name__ == "__main__": main()