#abc353d. D - Another Sigma Problem

D - Another Sigma Problem

Score: 400400 points

问题陈述

对于正整数 xxyy,定义 f(x,y)f(x, y) 如下:

  • xxyy 的十进制表示视为字符串,并将它们按此顺序连接起来,得到一个字符串 zzf(x,y)f(x, y) 的值是将 zz 解释为十进制整数时的值。

例如,f(3,14)=314f(3, 14) = 314f(100,1)=1001f(100, 1) = 1001

给定一个长度为 NN 的正整数序列 A=(A1,,AN)A = (A_1, \ldots, A_N)。求以下表达式的值对 998244353998244353 取模:

$\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(A_i,A_j)$。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

For positive integers xx and yy, define f(x,y)f(x, y) as follows:

  • Interpret the decimal representations of xx and yy as strings and concatenate them in this order to obtain a string zz. The value of f(x,y)f(x, y) is the value of zz when interpreted as a decimal integer.

For example, f(3,14)=314f(3, 14) = 314 and f(100,1)=1001f(100, 1) = 1001.

You are given a sequence of positive integers A=(A1,,AN)A = (A_1, \ldots, A_N) of length NN. Find the value of the following expression modulo 998244353998244353:

$\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(A_i,A_j)$.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1Ai1091 \leq A_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 \ldots ANA_N

Output

Print the answer.

Sample Input 1

3
3 14 15

Sample Output 1

2044
  • f(A1,A2)=314f(A_1, A_2) = 314
  • f(A1,A3)=315f(A_1, A_3) = 315
  • f(A2,A3)=1415f(A_2, A_3) = 1415

Thus, the answer is f(A1,A2)+f(A1,A3)+f(A2,A3)=2044f(A_1, A_2) + f(A_1, A_3) + f(A_2, A_3) = 2044.

Sample Input 2

5
1001 5 1000000 1000000000 100000

Sample Output 2

625549048

Be sure to calculate the value modulo 998244353998244353.