Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. 

As Devu is really a naughty kid, he wants the minimum value of his array a should be at least as much as the maximum value of his brother's array b. 

Now you have to help Devu in achieving this condition. You can perform multiple operations on the arrays. In a single operation, you are allowed to decrease or increase any element of any of the arrays by 1. Note that you are allowed to apply the operation on any index of the array multiple times.

You need to find minimum number of operations required to satisfy Devu's condition so that the brothers can play peacefully without fighting. 


-----Input-----

The first line contains two space-separated integers n, m (1 ≤ n, m ≤ 10^5). The second line will contain n space-separated integers representing content of the array a (1 ≤ a_{i} ≤ 10^9). The third line will contain m space-separated integers representing content of the array b (1 ≤ b_{i} ≤ 10^9).


-----Output-----

You need to output a single integer representing the minimum number of operations needed to satisfy Devu's condition.


-----Examples-----
Input
2 2
2 3
3 5

Output
3

Input
3 2
1 2 3
3 4

Output
4

Input
3 2
4 5 6
1 2

Output
0



-----Note-----

In example 1, you can increase a_1 by 1 and decrease b_2 by 1 and then again decrease b_2 by 1. Now array a will be [3; 3] and array b will also be [3; 3]. Here minimum element of a is at least as large as maximum element of b. So minimum number of operations needed to satisfy Devu's condition are 3.

In example 3, you don't need to do any operation, Devu's condition is already satisfied.

Difficulty: interview

Starter code:

Solutions:
"""
Codeforces Round 251 Div 2 Problem D

Author  : chaotic_iak
Language: Python 3.3.4
"""

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0:
        return inputs
    if mode == 1:
        return inputs.split()
    if mode == 2:
        return [int(x) for x in inputs.split()]

def write(s="\n"):
    if isinstance(s, list): s = " ".join(s)
    s = str(s)
    print(s, end="")

################################################### SOLUTION
n,m = read()
a = read()
b = read()
s = [(0,2)] + [(i,0) for i in a] + [(i,1) for i in b]
s.sort()
t = sum(b)
al = 0
br = m
mn = t
for i in range(1,n+m+1):
    t += (al-br) * (s[i][0] - s[i-1][0])
    mn = min(mn, t)
    if s[i][1]:
        br -= 1
    else:
        al += 1
print(mn)

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

arr = sorted(list(zip(a, [1] * n)) + list(zip(b, [2] * m)))

ans = 10**18

less_sum, less_cnt = 0, 0
more_sum, more_cnt = sum(b), m
for x, y in arr:
	if y == 1:
		less_sum += x
		less_cnt += 1
	else:
		more_sum -= x
		more_cnt -= 1
	ans = min(ans, (less_cnt * x - less_sum) + (more_sum - more_cnt * x))

print(ans)


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

arr = sorted(list(zip(a, [1] * n)) + list(zip(b, [2] * m)))

ans = 10**18

less_sum, less_cnt = 0, 0
more_sum, more_cnt = sum(b), m
for x, y in arr:
    if y == 1:
        less_sum += x
        less_cnt += 1
    else:
        more_sum -= x
        more_cnt -= 1
    ans = min(ans, (less_cnt * x - less_sum) + (more_sum - more_cnt * x))

print(ans)

from itertools import repeat

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

arr = sorted(list(zip(a, repeat(1))) + list(zip(b, repeat(2))))

ans = 10**18

less_sum, less_cnt = 0, 0
more_sum, more_cnt = sum(b), m
for x, y in arr:
	if y == 1:
		less_sum += x
		less_cnt += 1
	else:
		more_sum -= x
		more_cnt -= 1
	ans = min(ans, (less_cnt * x - less_sum) + (more_sum - more_cnt * x))

print(ans)


"""
Codeforces Round 251 Div 2 Problem D

Author  : chaotic_iak
Language: Python 3.3.4
"""

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0:
        return inputs
    if mode == 1:
        return inputs.split()
    if mode == 2:
        return [int(x) for x in inputs.split()]

def write(s="\n"):
    if isinstance(s, list): s = " ".join(s)
    s = str(s)
    print(s, end="")

################################################### SOLUTION
n,m = read()
a = read()
b = read()
s = [0] + a + b
s.sort()
t = sum(b)
mn = t
for i in range(n+m):
    t += (i-m) * (s[i+1] - s[i])
    mn = min(mn, t)
print(mn)

n, m = map(int, input().split())
a, b = list(map(int, input().split())), list(map(int, input().split()))
a.sort(); b.sort()
i = j = 0
s = t = sum(b)
while True:
    if i == n or (j < m and a[i] > b[j]): 
        if j == m: break
        x = b[j]
        j += 1
    else:
        x = a[i]
        i += 1
    t -= x
    s = min(t - x * (m - j - i), s)
print(s)

n, m = map(int, input().split())
a, b = list(map(int, input().split())), list(map(int, input().split()))
a.sort()
b.sort(reverse = True)
s = 0
for i in range(min(n, m)):
    if b[i] > a[i]: s += b[i] - a[i]
print(s)

R = lambda: map(int, input().split())
n, m = R()
a = sorted(R())
b = sorted(R())
b.reverse()
ans = 0
for i in range(min(n, m)):
    if b[i] > a[i]:
        ans += b[i] - a[i]
print(ans)

n, m = map(int, input().split())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
b.reverse()
ans = 0
for i in range(min(n, m)):
    if b[i] > a[i]:
        ans += b[i] - a[i]
print(ans)

n, m = map(int, input().split())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))[::-1]
ans = 0
for i in range(min(n, m)):
    if b[i] > a[i]:
        ans += b[i] - a[i]
print(ans)

#from sets import Set
n,m=list(map(int, input().split(' ')))
a=list(map(int, input().split(' ')))
b=list(map(int, input().split(' ')))
a.sort()
b.sort()

c=list(set(a+b))
c.sort()

ans = 1e+18
less=0
big=sum(b)
i1,k1=0,0
i2,k2=0,len(b)
for border in c:
	while(i1<len(a) and a[i1]<border):
		less+=a[i1]
		i1+=1
		k1+=1
	while(i2<len(b) and b[i2]<border):
		big-=b[i2]
		i2+=1
		k2-=1
	ans=min(ans, border*k1-less+big-border*k2)
print ((int)(ans))

import sys
import math


def solve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a.sort()
    b.sort()
    bcost = [0] * m
    for i in range(m - 2, -1, -1):
        valstoright = m - i - 1
        bcost[i] = bcost[i + 1] + valstoright * (b[i + 1] - b[i])
    acost = [0] * n
    for i in range(1, n):
        valstoleft = i
        acost[i] = acost[i-1] + valstoleft * (a[i] - a[i-1])
    res = 10000000000000000
    for i in range(m):
        amax = n - 1
        amin = 0
        while amin < amax:
            avg = (amin + amax + 1) // 2
            if a[avg] > b[i]: amax = avg - 1
            else: amin = avg
        # if a[amin] > b[i]: continue
        res = min(res, bcost[i] + acost[amin] + (amin+1)*(b[i] - a[amin]))
    for i in range(n):
        bmax = m - 1
        bmin = 0
        while bmin < bmax:
            avg = (bmax + bmin) // 2
            if b[avg] < a[i] : bmin = avg + 1
            else: bmax = avg
        # if b[bmin] < a[i]: continue
        # print(i, bmin, bcost[bmin], acost[i], (m - bmin)*(b[bmin] - a[i]))
        res = min(res, bcost[bmin] + acost[i] + (m - bmin)*(b[bmin] - a[i]))
    return max(res, 0)





if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
print(solve())

import sys

def solve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a.sort()
    b.sort()
    bcost = [0] * m
    for i in range(m - 2, -1, -1):
        valstoright = m - i - 1
        bcost[i] = bcost[i + 1] + valstoright * (b[i + 1] - b[i])
    acost = [0] * n
    for i in range(1, n):
        valstoleft = i
        acost[i] = acost[i-1] + valstoleft * (a[i] - a[i-1])
    res = 10000000000000000
    for i in range(m):
        amax = n - 1
        amin = 0
        while amin < amax:
            avg = (amin + amax + 1) // 2
            if a[avg] > b[i]: amax = avg - 1
            else: amin = avg
        res = min(res, bcost[i] + acost[amin] + (amin+1)*(b[i] - a[amin]))
    for i in range(n):
        bmax = m - 1
        bmin = 0
        while bmin < bmax:
            avg = (bmax + bmin) // 2
            if b[avg] < a[i] : bmin = avg + 1
            else: bmax = avg
        res = min(res, bcost[bmin] + acost[i] + (m - bmin)*(b[bmin] - a[i]))
    return max(res, 0)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
print(solve())

import sys

def solve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a.sort()
    b.sort()
    bcost = [0] * m
    for i in range(m - 2, -1, -1):
        valstoright = m - i - 1
        bcost[i] = bcost[i + 1] + valstoright * (b[i + 1] - b[i])
    acost = [0] * n
    for i in range(1, n):
        valstoleft = i
        acost[i] = acost[i-1] + valstoleft * (a[i] - a[i-1])
    res = 10000000000000000
    for i in range(m):
        amax = n - 1
        amin = 0
        while amin < amax:
            avg = (amin + amax + 1) // 2
            if a[avg] > b[i]: amax = avg - 1
            else: amin = avg
        res = min(res, bcost[i] + acost[amin] + (amin+1)*(b[i] - a[amin]))
    for i in range(n):
        bmax = m - 1
        bmin = 0
        while bmin < bmax:
            avg = (bmax + bmin) // 2
            if b[avg] < a[i] : bmin = avg + 1
            else: bmax = avg
        res = min(res, bcost[bmin] + acost[i] + (m - bmin)*(b[bmin] - a[i]))
    return max(res, 0)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
print(solve())

n,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort(reverse=True)
ans = 0
for i in range(min(n,m)):
    if b[i] > a[i]:
        ans+= b[i]-a[i]
print(ans)

#it's me

n,m = list(map( int,input().split() ))
a = sorted( map( int,input().split() ) )
b = sorted( map( int,input().split() ) )
b.reverse()
Res = 0
for i in range( min(n,m) ):
    if a[i]<b[i]:
        Res += b[i]-a[i]
print(Res)


def main():
    n,m = list(map(int,input().split()))
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    
    #a>>>>>
    #b<<<<<
    def f(m):
        ans = 0
        for i in a:
            ans+=max(0,m-i)
        for i in b:
            ans+=max(0,i-m)
        return ans
    l = 0
    r = 10**9 + 3
    
    while r-l>2:
        m1 = l+ (r-l)//3
        m2 = m1+ (r-l)//3
        if f(m1)>=f(m2):
            l = m1
        else:
            r = m2
    
    print(min(f(l),f(l+1),f(r)))
main()






n, m = list(map(int, input().split()))
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()), reverse = True)
ans = 0
#print(a, b)
for i in range(min(n, m)):
	ans += max(0, b[i] - a[i])

print(ans)


def costo(a, b, t):
    resultado = 0
    for elem in a:
        resultado += max(t - elem, 0)
    for elem in b:
        resultado += max(elem - t, 0)
    return resultado


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

inf, sup = min(a), max(b)
while inf < sup:
    t = (inf + sup)//2
    if costo(a, b, t+1) - costo(a, b, t) >= 0:
        sup = t
    else:
        inf = t + 1

print(costo(a, b, inf))



import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return list(map(int if arg==0 else str,input().split()))
#------------------------------------------------------------------

n,m = mapi()
a = list(mapi())
b = list(mapi())
a.sort()
b.sort(reverse=True)

res = 0
i =0
while i<n and i<m and a[i]<b[i]:
    res+= b[i]-a[i]
    i+=1
print(res)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------

n,m = mapi()
a = list(mapi())
b = list(mapi())
res = 10**18
l = 1
r = 10**9
cnt =0

def check(k):
    ans = 0
    for i in a:
        if i<k: ans+=k-i
    for i in b:
        if i>k: ans+=i-k
    return ans

while r-l>=0 and cnt<=64:
    cnt+=1
    mid1 = l+(r-l)//3
    mid2 = r-(r-l)//3
    if mid1-l<0 or r-mid1<0 or mid2-l<0 or r-mid2<0:
        break
    ans1 = check(mid1)
    ans2 = check(mid2)
    res = min(res,ans1,ans2)
    if ans1<ans2:
        r = mid2
    else:
        l = mid1
print(res)

def binarySearchCount(arr, n, key): 
  
    left = 0
    right = n - 1
  
    count = 0
  
    while (left <= right):  
        mid = int((right + left) / 2) 
  
        # Check if middle element is 
        # less than or equal to key 
        if (arr[mid] < key):  
  
            # At least (mid + 1) elements are there 
            # whose values are less than 
            # or equal to key 
            count = mid + 1
            left = mid + 1
          
        # If key is smaller, ignore right half 
        else: 
            right = mid - 1
      
    return count 
def countGreater(arr, n, k): 
    l = 0
    r = n - 1
  
    # Stores the index of the left most element 
    # from the array which is greater than k 
    leftGreater = n 
  
    # Finds number of elements greater than k 
    while (l <= r): 
        m = int(l + (r - l) / 2) 
  
        # If mid element is greater than 
        # k update leftGreater and r 
        if (arr[m] > k): 
            leftGreater = m 
            r = m - 1
  
        # If mid element is less than 
        # or equal to k update l 
        else: 
            l = m + 1
  
    # Return the count of elements  
    # greater than k 
    return (n - leftGreater) 
class SegmentTree:
    def __init__(self, data, default=0, func=lambda a,b:a+b):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()
 
        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])
 
    def __delitem__(self, idx):
        self[idx] = self._default
 
    def __getitem__(self, idx):
        return self.data[idx + self._size]
 
    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1
 
    def __len__(self):
        return self._len
 
    def query(self, start, stop):
        if start == stop:
            return self.__getitem__(start)
        stop += 1
        start += self._size
        stop += self._size
 
        res = self._default
        while start < stop:
            if start & 1:
                res = self._func(res, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res = self._func(res, self.data[stop])
            start >>= 1
            stop >>= 1
        return res
 
    def __repr__(self):
        return "SegmentTree({0})".format(self.data)
m,n=map(int,input().split())
b=list(map(int,input().split()))
a=list(map(int,input().split()))
#a=[100]*10
a.sort()
b.sort()
tot=9999999999999999999999999999999
s=SegmentTree(a)
#print(s.query(n,n-1))
s1=SegmentTree(b)
for i in range(n):
    c=binarySearchCount(b,m,a[i])
    #print(a[i],c)
    ans=c*a[i]-s1.query(0,c-1)-(n-1-i)*a[i]+s.query(i+1,n-1)
    #print(ans)
    tot=min(ans,tot)    
for i in range(m):
    c=countGreater(a,n,b[i])
   # print(b[i],c)
    ans=-(c)*b[i]+s.query(n-c,n-1)-s1.query(0,i-1)+(i)*b[i]
   # print(ans)
    tot=min(ans,tot)
print(tot)

n, m  = list(map(int, input().split()))
a  = list(map(int, input().split()))
b  = list(map(int, input().split()))
a_min = min(a)
b_max = max(b)
if a_min >= b_max:
    print(0)
else:
    a = sorted([i for i in a if i < b_max])
    n = len(a)
    aa = [0] * (n + 1)
    for i in range(n):
        aa[i + 1] = aa[i] + a[i]
    b = sorted([i for i in b if i > a_min])
    m = len(b)
    bb = [0] * (m + 1)
    for i in range(m - 1, -1, -1):
        bb[i] = bb[i + 1] + b[i]
    output = float('inf')
    i = 0
    j = 0
    while i < n or j < m:
        if i == n:
            k =  b[j]
        elif j == m:
            k = a[i]
        else:
            k = min(a[i], b[j])
        while i < n and a[i] <= k:
            i += 1
        while j < m and b[j] <= k:
            j += 1
        output = min(output, k * (i - m + j) - aa[i] + bb[j])
    print(int(output))



from sys import stdin
n,m = map(int,stdin.readline().split())
a = list(map(int,stdin.readline().split()))
b = list(map(int,stdin.readline().split()))
l = min(min(a),min(b))
r = max(max(a),max(b))
ans = 10**20
while l<=r:
    lo = l+(r-l)//3
    hi = r-(r-l)//3
    cou = 0
    for i in a:
        cou += max(0,lo-i)
    for j in b:
        cou += max(0,j-lo)
    cou1 = 0
    for i in a:
        cou1 += max(0,hi-i)
    for j in b:
        cou1 += max(0,j-hi)
    if cou1>cou:
        r = hi-1
    elif cou1<cou:
        l = lo+1
    else:
        l = lo+1
        r = hi-1
    ans = min(ans,cou,cou1)
print(ans)

'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file=1


 
def solve():


    n,m=mi()
    a=li()
    b=li()
    a.sort()
    b.sort()
    if b[-1]<=a[0]:
        print(0)
        return
    pre=[0]*n
    for i in range(1,n):
        pre[i]+=pre[i-1]
        pre[i]+=i*(a[i]-a[i-1])

    suff=[0]*m
    for i in range(m-2,-1,-1):
        suff[i]+=suff[i+1]
        suff[i]+=(m-i-1)*(b[i+1]-b[i])

    def fun(m1):
        x=bisect(a,m1)-1
        y=bisect(b,m1)-1
        ans=0
        if x==n:
            x-=1
        ans+=pre[x]
        ans+=(m1-a[x])*(x+1)
        # print(x,ans)
        if y>=(m-1):
            return ans
        if y==0:
            y-=1
        ans+=(b[y+1]-m1)*(m-y-1)
        ans+=suff[y+1]
        return ans
    
    
    l=1
    r=int(1e9+5)
    while(l<=r):
        mid=l+(r-l)//2
        x=fun(mid)
        if mid==1:
            x1=fun(mid+1)
            if(x>x1):
                l=mid+1
                ans=x1
            else:
                # print(mid)
                print(max(x,0))
                return

        x1=fun(mid-1)
        x2=fun(mid+1)
        if(x1<x2):
            if(x1<x):
                r=mid-1
                ans=x1
            else:
                # print(mid)
                print(max(x,0))
                return
        else:
            if(x2<x):
                l=mid+1
            else:
                # print(mid)
                print(max(x,0))
                return
    



    










        
def __starting_point():

    if(file):

        if path.exists('input.txt'):
            sys.stdin=open('input.txt', 'r')
            sys.stdout=open('output.txt','w')
        else:
            input=sys.stdin.readline
    solve()
__starting_point()