AT_abc437_d [ABC437D] Sum of Differences
Description
You are given a length- $ N $ sequence of positive integers $ A = (A_1, A_2, \dots, A_N) $ and a length- $ M $ sequence of positive integers $ B = (B_1, B_2, \dots, B_M) $ .
Find the value of $ \displaystyle \sum_{i=1}^{N} \sum_{j=1}^{M} |A_i - B_j| $ , modulo $ 998244353 $ .
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ M $ $ A_1 $ $ A_2 $ $ \cdots $ $ A_N $ $ B_1 $ $ B_2 $ $ \cdots $ $ B_M $
Output Format
Output the answer in one line.
Explanation/Hint
### Sample Explanation 1
The answer is $ |1-3| + |1-1| + |6-3| + |6-1| + |9-3| + |9-1| + |2-3| + |2-1| = 2+0+3+5+6+8+1+1 = 26 $ .
### Constraints
- $ 1 \leq N,M \leq 3 \times 10^5 $
- $ 1 \leq A_i, B_j < 998244353 $
- All input values are integers.