#P1158A. The Party and Sweets
The Party and Sweets
Description
boys and girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from to and all girls are numbered with integers from to . For all the minimal number of sweets, which -th boy presented to some girl is equal to and for all the maximal number of sweets, which -th girl received from some boy is equal to .
More formally, let be the number of sweets which the -th boy give to the -th girl. Then is equal exactly to the minimum among values and is equal exactly to the maximum among values .
You are interested in the minimum total number of sweets that boys could present, so you need to minimize the sum of for all such that and . You are given the numbers and , determine this number.
The first line contains two integers and , separated with space — the number of boys and girls, respectively (). The second line contains integers , separated by spaces — is equal to the minimal number of sweets, which -th boy presented to some girl (). The third line contains integers , separated by spaces — is equal to the maximal number of sweets, which -th girl received from some boy ().
If the described situation is impossible, print . 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 and , separated with space — the number of boys and girls, respectively (). The second line contains integers , separated by spaces — is equal to the minimal number of sweets, which -th boy presented to some girl (). The third line contains integers , separated by spaces — is equal to the maximal number of sweets, which -th girl received from some boy ().
Output
If the described situation is impossible, print . In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied.
Note
In the first test, the minimal total number of sweets, which boys could have presented is equal to . This can be possible, for example, if the first boy presented and sweets, the second boy presented and sweets and the third boy presented and 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 .
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 . This can be possible, for example, if the first boy presented , , 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 .