def print_sum():

	d = int(input())

	if d == 0: return False

	n, m = int(input()), int(input())

	S = [int(input()) for _ in range(n-1)]

	K = sorted([int(input()) for _ in range(m)], reverse=True)

	S = sorted(S) + [d]

	S_k = [[] for _ in range(len(S))]

	for i, s in enumerate(S):

		for j in range(len(K)-1, -1, -1):

			if K[j] <= s:

				S_k[i].append(K.pop())

			else:

				break

	sum = 0

	S = [0] + S

	for i, sk in enumerate(S_k):

		for k in sk:

			sum += min(k-S[i], S[i+1]-k)

	print(sum)

	return True



while print_sum():

	pass
def find(l, e):

	start, end = 0, len(l)

	while True:

		mid = (start+end)//2

		if l[mid] == e: 

			return (e, e)

		elif (l[mid] > e):

			if (l[mid-1] < e):

				return (l[mid-1], l[mid])

			end = mid

			continue

		elif (l[mid] < e):

			if (l[mid+1] > e):

				return (l[mid], l[mid+1])

			start = mid



def print_sum():

	d = int(input())

	if d == 0: return False

	n, m = int(input()), int(input())

	S = [int(input()) for _ in range(n-1)]

	K = [int(input()) for _ in range(m)]

	S = [0] + sorted(S) + [d]

	sum = 0

	for k in K:

		low, high = find(S, k)

		sum += min(k-low, high-k)

	print(sum)

	return True



while (print_sum()):

	pass
def print_sum():
    d = int(input())
    if d == 0:
        return False
    n, m = int(input()), int(input())
    S = [int(input()) for _ in range(n - 1)]
    K = sorted([int(input()) for _ in range(m)], reverse=True)
    S = sorted(S) + [d]
    S_k = [[] for _ in range(len(S))]
    for i, s in enumerate(S):
        for j in range(len(K) - 1, -1, -1):
            if K[j] <= s:
                S_k[i].append(K.pop())
            else:
                break
    sum = 0
    S = [0] + S
    for i, sk in enumerate(S_k):
        for k in sk:
            sum += min(k - S[i], S[i + 1] - k)
    print(sum)
    return True


while print_sum():
    pass

def find(l, e):
    start, end = 0, len(l)
    while True:
        mid = (start + end) // 2
        if l[mid] == e:
            return (e, e)
        elif l[mid] > e:
            if l[mid - 1] < e:
                return (l[mid - 1], l[mid])
            end = mid
            continue
        elif l[mid] < e:
            if l[mid + 1] > e:
                return (l[mid], l[mid + 1])
            start = mid


def print_sum():
    d = int(input())
    if d == 0:
        return False
    n, m = int(input()), int(input())
    S = [int(input()) for _ in range(n - 1)]
    K = [int(input()) for _ in range(m)]
    S = [0] + sorted(S) + [d]
    sum = 0
    for k in K:
        low, high = find(S, k)
        sum += min(k - low, high - k)
    print(sum)
    return True


while print_sum():
    pass

+def find(l, e): +    start, end = 0, len(l) +    while True: +        mid = (start + end) // 2 +        if l[mid] == e: +            return (e, e) +        elif l[mid] > e: +            if l[mid - 1] < e: +                return (l[mid - 1], l[mid]) +            end = mid +            continue +        elif l[mid] < e: +            if l[mid + 1] > e: +                return (l[mid], l[mid + 1]) +            start = mid + + -    K = sorted([int(input()) for _ in range(m)], reverse=True) -    S = sorted(S) + [d] -    S_k = [[] for _ in range(len(S))] -    for i, s in enumerate(S): -        for j in range(len(K) - 1, -1, -1): -            if K[j] <= s: -                S_k[i].append(K.pop()) -            else: -                break +    K = [int(input()) for _ in range(m)] +    S = [0] + sorted(S) + [d] -    S = [0] + S -    for i, sk in enumerate(S_k): -        for k in sk: -            sum += min(k - S[i], S[i + 1] - k) +    for k in K: +        low, high = find(S, k) +        sum += min(k - low, high - k)