from heapq import * def main(): n, m, l = list(map(int, input().split())) A = [] N = 10**3+1 for a in list(map(int, input().split())): A.append(a+N) for a in list(map(int, input().split())): A.append(-a-N) A.sort(key = lambda x: abs(x)) B = [0] * (n+m+1) for i in range(n+m): B[i+1] = B[i]+A[i] E = [-1]*(n+m+1) inf = 1 << 60 dp = [inf] * (n+m+1) dp[0] = 0 now = 0 E[0] = 0 for i in range(1, n+m+1): a = A[i-1] if 0 < a: now += 1 else: now -= 1 p = E[now] if p == -1: dp[i] = 0 else: dp[i] = dp[p] + abs(B[i]-B[p]) E[now] = i hq = [] LR = [[i-1, i+1] for i in range(n+m)] for i in range(n+m-1): if A[i] * A[i+1] < 0: heappush(hq, (abs(A[i]+A[i+1]), i, i+1)) ans = 0 used = set() for _ in range(l): while 1: cost, i0, i1 = heappop(hq) if LR[i0][1] != i1 or LR[i1][0] != i0 or i0 in used or i1 in used: pass else: break ans += cost used.add(i0) used.add(i1) j0, j1 = LR[i0][0], LR[i1][1] if 0 <= j0 < n+m: LR[j0][1] = j1 if 0 <= j1 < n+m: LR[j1][0] = j0 if 0 <= j0 and j1 < n+m and A[j0]*A[j1] < 0: heappush(hq, (dp[j1+1]-dp[j0]-dp[j1]+dp[j0+1], j0, j1)) return ans print(main())