#P1158A. The Party and Sweets

    ID: 4529 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>binary searchconstructive algorithmsgreedyimplementationmathsortingstwo pointers*1500

The Party and Sweets

Description

nn boys and mm girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from 11 to nn and all girls are numbered with integers from 11 to mm. For all 1in1 \leq i \leq n the minimal number of sweets, which ii-th boy presented to some girl is equal to bib_i and for all 1jm1 \leq j \leq m the maximal number of sweets, which jj-th girl received from some boy is equal to gjg_j.

More formally, let ai,ja_{i,j} be the number of sweets which the ii-th boy give to the jj-th girl. Then bib_i is equal exactly to the minimum among values ai,1,ai,2,,ai,ma_{i,1}, a_{i,2}, \ldots, a_{i,m} and gjg_j is equal exactly to the maximum among values b1,j,b2,j,,bn,jb_{1,j}, b_{2,j}, \ldots, b_{n,j}.

You are interested in the minimum total number of sweets that boys could present, so you need to minimize the sum of ai,ja_{i,j} for all (i,j)(i,j) such that 1in1 \leq i \leq n and 1jm1 \leq j \leq m. You are given the numbers b1,,bnb_1, \ldots, b_n and g1,,gmg_1, \ldots, g_m, determine this number.

The first line contains two integers nn and mm, separated with space — the number of boys and girls, respectively (2n,m1000002 \leq n, m \leq 100\,000). The second line contains nn integers b1,,bnb_1, \ldots, b_n, separated by spaces — bib_i is equal to the minimal number of sweets, which ii-th boy presented to some girl (0bi1080 \leq b_i \leq 10^8). The third line contains mm integers g1,,gmg_1, \ldots, g_m, separated by spaces — gjg_j is equal to the maximal number of sweets, which jj-th girl received from some boy (0gj1080 \leq g_j \leq 10^8).

If the described situation is impossible, print 1-1. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied.

Input

The first line contains two integers nn and mm, separated with space — the number of boys and girls, respectively (2n,m1000002 \leq n, m \leq 100\,000). The second line contains nn integers b1,,bnb_1, \ldots, b_n, separated by spaces — bib_i is equal to the minimal number of sweets, which ii-th boy presented to some girl (0bi1080 \leq b_i \leq 10^8). The third line contains mm integers g1,,gmg_1, \ldots, g_m, separated by spaces — gjg_j is equal to the maximal number of sweets, which jj-th girl received from some boy (0gj1080 \leq g_j \leq 10^8).

Output

If the described situation is impossible, print 1-1. In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied.

Sample Input 1

3 2
1 2 1
3 4

Sample Output 1

12

Sample Input 2

2 2
0 1
1 0

Sample Output 2

-1

Sample Input 3

2 3
1 0
1 1 2

Sample Output 3

4

Note

In the first test, the minimal total number of sweets, which boys could have presented is equal to 1212. This can be possible, for example, if the first boy presented 11 and 44 sweets, the second boy presented 33 and 22 sweets and the third boy presented 11 and 11 sweets for the first and the second girl, respectively. It's easy to see, that all conditions are satisfied and the total number of sweets is equal to 1212.

In the second test, the boys couldn't have presented sweets in such way, that all statements satisfied.

In the third test, the minimal total number of sweets, which boys could have presented is equal to 44. This can be possible, for example, if the first boy presented 11, 11, 22 sweets for the first, second, third girl, respectively and the second boy didn't present sweets for each girl. It's easy to see, that all conditions are satisfied and the total number of sweets is equal to 44.