$n$ boys and $m$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $1$ to $n$ and all girls are numbered with integers from $1$ to $m$. For all $1 \leq i \leq n$ the minimal number of sweets, which $i$-th boy presented to some girl is equal to $b_i$ and for all $1 \leq j \leq m$ the maximal number of sweets, which $j$-th girl received from some boy is equal to $g_j$.

More formally, let $a_{i,j}$ be the number of sweets which the $i$-th boy give to the $j$-th girl. Then $b_i$ is equal exactly to the minimum among values $a_{i,1}, a_{i,2}, \ldots, a_{i,m}$ and $g_j$ is equal exactly to the maximum among values $b_{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 $a_{i,j}$ for all $(i,j)$ such that $1 \leq i \leq n$ and $1 \leq j \leq m$. You are given the numbers $b_1, \ldots, b_n$ and $g_1, \ldots, g_m$, determine this number. 


-----Input-----

The first line contains two integers $n$ and $m$, separated with space — the number of boys and girls, respectively ($2 \leq n, m \leq 100\,000$). The second line contains $n$ integers $b_1, \ldots, b_n$, separated by spaces — $b_i$ is equal to the minimal number of sweets, which $i$-th boy presented to some girl ($0 \leq b_i \leq 10^8$). The third line contains $m$ integers $g_1, \ldots, g_m$, separated by spaces — $g_j$ is equal to the maximal number of sweets, which $j$-th girl received from some boy ($0 \leq g_j \leq 10^8$).


-----Output-----

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


-----Examples-----
Input
3 2
1 2 1
3 4

Output
12
Input
2 2
0 1
1 0

Output
-1
Input
2 3
1 0
1 1 2

Output
4


-----Note-----

In the first test, the minimal total number of sweets, which boys could have presented is equal to $12$. This can be possible, for example, if the first boy presented $1$ and $4$ sweets, the second boy presented $3$ and $2$ sweets and the third boy presented $1$ and $1$ 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 $12$.

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 $4$. This can be possible, for example, if the first boy presented $1$, $1$, $2$ 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 $4$.

Difficulty: competition

Starter code:

Solutions:
n,m=map(int,input().split())
b=list(map(int,input().split()))
g=list(map(int,input().split()))
if max(b)>min(g):
    print(-1)
else:
    maxi=0
    maxi2=0
    for guy in b:
        if guy>maxi:
            maxi2,maxi=maxi,guy
        elif guy>maxi2:
            maxi2=guy
    sumi=m*sum(b)+sum(g)-m*maxi+maxi-maxi2
    if maxi in g:
        sumi-=(maxi-maxi2)
    print(sumi)

import sys
import bisect
input = sys.stdin.readline

n,m=list(map(int,input().split()))
B=list(map(int,input().split()))
G=list(map(int,input().split()))

B.sort()
G.sort()

if max(B)>min(G):
    print(-1)
    return

ANS=sum(B)*m
MAX=B[-1]
first=m
for i in range(m):
    if G[i]>MAX:
        first=i
        break


if first==0:
    ANS+=sum(G[1:])-MAX*(m-1)
    ANS+=G[0]-B[-2]

    print(ANS)
    return

else:
    ANS+=sum(G[first:])-MAX*(m-first)

    print(ANS)


    
    


N, M = list(map(int, input().split()))
A = sorted([int(a) for a in input().split()])[::-1]
B = sorted([int(a) for a in input().split()])
if A[0] > B[0]:
    print(-1)
else:
    ans = 0
    for a in A:
        ans += a * M
    
    i = 0
    j = M - 1
    for b in B:
        if b > A[0]:
            ans += b - A[i]
            j -= 1
            if j == 0:
                i += 1
                j = M - 1
    print(ans)


n, m = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a.sort()
b.sort()
if a[-1] > b[0]:
    print(-1)
    return

if a[-1] == b[0]:
    print(sum(b) + sum(a[:-1]) * m)
else:
    print(sum(b) + a[-1] + sum(a[:-1]) * m - a[-2])

a ,b= (int(i) for i in input().split())
c = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
leng = len(d)
e = sum(c)*leng
c.sort()
d.sort()
if c[-1] > d[0]:
    print(-1)
else:
    count = 0
    for i in range(len(d)):
        count += d[i]
    if c[-1] == d[0]:
        count -= c[-1] * leng
    else:
        count -= c[-1] * (leng-1)
        count -= c[-2]
    ans = e + count
    print(ans)

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
if a[-1] > b[0]: print(-1)
elif a[-1] == b[0]: print(sum(b) + sum(a[:-1]) * m)
else: print(sum(b) + a[-1] + sum(a[:-1]) * m - a[-2])

nBoys, nGirls = map(int, input().split())
boys = sorted(map(int, input().split()), reverse=True)
girls = sorted(map(int, input().split()))
if boys[0] > girls[0]:
    print(-1)
    return
ret = sum(girls)
for i in range(1, nBoys):
    ret += boys[i] * nGirls
if boys[0] != girls[0]:
    ret -= girls[0] - boys[0]
    ret += girls[0] - boys[1]
print(ret)


mx1 = 0
mx2 = 0
sum = 0

def parsare(s, lista):
    number = ""
    for l in s:
        if l != " ":
            number += l
        else:
            lista.append(int(number))
            number = ""
    lista.append(int(number))

row1 = []
row2 = []
row3 = []

sir = input()
parsare(sir, row1)

sir = input()
parsare(sir, row2)

sir = input()
parsare(sir, row3)

for nr in row2:
    sum += nr * row1[1]
    if nr > mx1:
        mx2 = mx1
        mx1 = nr
    elif nr > mx2:
        mx2 = nr

ok = True
ok2 = False

for nr in row3:
    dif = nr - mx1
    if dif < 0:
        ok = False
        break
    elif dif == 0:
        ok2 = True
    sum += dif

if ok and ok2:
    print(sum)
elif ok:
    print(sum + mx1 - mx2)
else:
    print(-1)


n,m=list(map(int,input().split()))
b=list(map(int,input().split()))
g=list(map(int,input().split()))
b=sorted(b,reverse=True)
g=sorted(g,reverse=True)
s=0
if min(g)<max(b):
   print(-1)
else:
   for i in b:
      s+=i*m
   c=m-1
   k=0
   for i in g:
      if i==b[k]:
         continue
      if c==0:
         k+=1
         c=m-1
      if c!=0 and i>b[k]:
         c-=1
         s+=i-b[k]
   print(s)      


'''input
3 2
1 2 1
3 4
'''
n, m = [int(x) for x in input().split()]

pir = [int(x) for x in input().split()]
ant = [int(x) for x in input().split()]

ats = sum(pir)*m

did = max(pir)

antmaz = min(ant)

if antmaz < did:
	print(-1)
	return

pir.sort(reverse=True)
ant.sort()

for i in range(1, m):
	ats += ant[i] - did

if ant[0] != did:
	ats += ant[0] - pir[1]

print(ats)


def main():
  n, m = list(map(int, input().split()))

  bs = list(map(int, input().split()))
  gs = list(map(int, input().split()))

  num_sweets = m * sum(bs)
  b = sorted(bs)
  del bs
  remaining_slots = [m-1] * n

  for j, g in enumerate(gs):
    lval_index = n-1
    while lval_index >= 0:
      if b[lval_index] > g:
        return -1
      if b[lval_index] == g or remaining_slots[lval_index]:
        break
      lval_index -= 1
    if lval_index < 0:
      return -1
    else:
      b_val = b[lval_index]
      if b_val != g:
        remaining_slots[lval_index] -= 1
        num_sweets = num_sweets + (g - b_val)
  return num_sweets

num_sweets = main()
print(num_sweets)


from sys import stdin, stdout

def take_input():
	return [int(x) for x in stdin.readline().rstrip().split()]

def min_sweets(b, g, b_sweet, g_sweet):
	if (len(b_sweet) == 0 or len(g_sweet) == 0):
		return -1
	total_sum = 0
	max_b = b_sweet[0]
	second_max_b = -1
	max_ind = 0
	for index, el in enumerate(b_sweet):
		if(el > max_b):
			max_b = el
			max_ind = index
		total_sum += (el*g)
	for index, el in enumerate(b_sweet):
		if(el <= max_b and el > second_max_b and max_ind != index):
			second_max_b = el

	min_g = g_sweet[0]
	for i in g_sweet:
		if i < min_g:
			min_g = i
		total_sum += i
	if (max_b > min_g):
		return -1
	if max_b == min_g:
		total_sum -= (max_b * g)
	if max_b < min_g:
		total_sum = total_sum - (max_b * (g-1))
		total_sum = total_sum - second_max_b
	return total_sum
	

b, g = take_input()
b_sweet = take_input()
g_sweet = take_input()
stdout.write(str(min_sweets(b, g, b_sweet, g_sweet)) + "\n")

# stdout.write( str(b*g) + "\n" )
# stdout.write( str(b_sweet[0]) + "\n" )


l = input().split(" ")
n = int(l[0])
m = int(l[1])
B = input().split(" ")
B = [int(x) for x in B]
J = input().split(" ")
J = [int(x) for x in J]

J.sort()
B.sort()

if J[0] < B[-1]:
    print(-1)
    return
    
k=n-1
sm= sum(B)
l= (sm-B[-1])*m
s=l
for i in J:
    s+=i

if B[-1] != J[0] :
    s=s+B[-1]-B[-2]
print(s)

n,m=map(int,input().split())
b=list(map(int,input().split()))
g=list(map(int,input().split()))
b.sort()
g.sort()
if g[0]<b[n-1]:print(-1)
elif g[0]==b[n-1]:print(m*(sum(b)-b[n-1])+sum(g))
else:print(m*(sum(b)-b[n-1])+sum(g)+b[n-1]-b[n-2])

R = lambda: map(int, input().split())
n,m = R()
a = list(R())
b = list(R())
a.sort()
b.sort()
t = sum(a)*m + sum(b) - a[-1]*m

if a[-1] >  b[0]:
    print(-1)
elif a[-1] == b[0]:
    print(t)
else:
    print(t+a[-1]-a[-2])

R = lambda: map(int, input().split())
n,m = R()
a = list(R())
b = list(R())
a.sort()
b.sort()
t = sum(a)*m + sum(b) - a[-1]*m

if a[-1] >  b[0]:
    print(-1)
elif a[-1] == b[0]:
    print(t)
else:
    print(t+a[-1]-a[-2])

import bisect

def party_sweet(b, g):
    maxb = max(b)
    ming = min(g)
    if maxb > ming:
        return -1
    elif maxb == ming:
        return (sum(b) - maxb)* len(g) + sum(g)
    else:
        return (sum(b))* len(g) + sum(g) - maxb * (len(g) - 1) - sorted(b)[-2]



def main():
    n, m = map(int, input().split())
    b = list(map(int, input().split()))
    g = list(map(int, input().split()))

    print(party_sweet(b, g))

def __starting_point():
    main()
__starting_point()

n, m = list(map(int, input().split()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
dop = sum(a) * m
a.sort()
b.sort()
if a[-1] > b[0]:
	print(-1)
else:
	ans = 0
	for i in range(m):
		ans += b[i]
	if a[-1] == b[0]:
		ans -= a[-1] * m
	else:
		ans -= a[-1] * (m - 1)
		ans -= a[-2]
	ans = ans + dop
	print(ans)


n, m = list(map(int, input().split()))

b = list(map(int, input().split()))
g = list(map(int, input().split()))


x = max(b)


y = min(g)


if x > y:
	print(-1)

elif x == y:
	print(sum(b) * m + sum(g) - x * m)

else:
	
	m1, m2 = 0, 0
	
	for c in b:
		if c >= m1:
			m1, m2 = c, m1
		elif c >= m2:
			m2 = c
	#print(m1, m2)
	print(sum(b) * m + sum(g) - x * (m - 1) - m2)


#Bhargey Mehta (Sophomore)
#DA-IICT, Gandhinagar
import sys, math, queue, bisect
#sys.stdin = open("input.txt", "r")
MOD = 10**9+7
sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
b = sorted(map(int, input().split()))
g = sorted(map(int, input().split()))
if b[n-1] > g[0]:
    print(-1)
    return
ans = 0
found = False
for i in range(n-1):
    ans += b[i]*m
ans += sum(g)
for j in range(m):
    if g[j] == b[-1]:
        found = True
if not found:
    ans -= b[-2]
    ans += b[-1]
print(ans)

n, m = list(map(int, input().split()))
b = list(map(int, input().split()))
g = list(map(int, input().split()))
x = max(b)
y = min(g)
if x > y:
    print(-1)
elif x == y:
    print(sum(b) * m + sum(g) - x * m)
else:
    m1, m2 = 0, 0
    for c in b:
        if c >= m1:
            m1, m2 = c, m1
        elif c >= m2:
            m2 = c
#print(m1, m2)
    print(sum(b) * m + sum(g) - x * (m - 1) - m2)



#https://codeforces.com/contest/1158/problem/A

n, m = map(int, input().split())

boys = list(map(int,input().split()))
girls = list(map(int,input().split()))

boys.sort()
girls.sort()
res = 0
if boys[-1] > girls[0]:
    print(-1)
    return

for b in boys:
    res += (b*len(girls))
if boys[-1] == girls[0]:
    for g in girls:
        res += (g - boys[-1])
else:
    res += (girls[0] - boys[-2])
    for g in girls[1:]:
        res += (g - boys[-1])
print(res)

n,m = map(int,input().split())

b=list(map(int,input().split()))
g=list(map(int,input().split()))

b.sort()
g.sort()

if g[0]<b[n-1]:print(-1)
elif g[0]==b[n-1]:print(m*(sum(b)-b[n-1])+sum(g))
else:print(m*(sum(b)-b[n-1])+sum(g)+b[n-1]-b[n-2])

R = lambda :list(map(int,input().split()))
n,m= R()
a = R()
b = R()
a.sort()
b.sort()
M = a[n-1]
test = 0 
s = 0
for j in range(m) :
	if b[j] < M :
		test = 1 
		break



if test == 1 :
	print(-1)
else :
	k = 0
	for i in range(m) :
		if b[i] == a[n-1] :
			k = 1

	if k == 1 :
		s = sum(b) + (sum(a) - a[n-1])*m
		print(s)	
	else :
		s = sum(b) + (sum(a) - a[n-1] - a[n-2])*m +  a[n-2]*(m-1) + a[n-1]
		print(s)



from bisect import bisect
n, m = map(int, input().split())
b = sorted(map(int, input().split()))
g = sorted(map(int, input().split()))
if g[0] > b[-1]:
    print(sum(g) + b[-1] + b[-2] * (m - 1) + m * sum(b[:-2]))
elif g[0] == b[-1]:
    i = bisect(g, b[-1])
    print(sum(g) + m * sum(b[:-1]))
else:
    print(-1)