## https://yukicoder.me/problems/no/1612 MOD = 998244353 def main(): N = int(input()) A = input().split() A.sort() 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()