n, m = map(int, input().split()) inf = 10 ** 10 A = [-inf] + list(map(int, input().split())) + [inf] B = list(map(int, input().split())) ap = 1 lst = [] ans = 0 for b in B: if b > A[ap]: if lst: lst = [A[ap - 1]] + lst + [A[ap]] ans += A[ap] - A[ap - 1] ma = 0 for i in range(len(lst) - 1): ma = max(ma, lst[i + 1] - lst[i]) ans -= ma while b > A[ap]: ap += 1 lst = [] lst.append(b) lst = [A[ap - 1]] + lst + [A[ap]] ans += A[ap] - A[ap - 1] ma = 0 for i in range(len(lst) - 1): ma = max(ma, lst[i + 1] - lst[i]) ans -= ma print(ans)