mapping = {}

def find(l, e, start, end):

	global mapping

	if e in mapping:

		return mapping[e]

	mid = (start+end)//2

	if (l[mid] == e):

		mapping[e] = (e, e)

		return mapping[e]

	elif (l[mid] > e):

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

			mapping[e] = (l[mid-1], l[mid])

			return mapping[e]

		return find(l, e, start, mid)

	elif (l[mid] < e):

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

			mapping[e] =  (l[mid], l[mid+1])

			return mapping[e]

		return find(l, e, mid, end)



def print_sum(input):

	global mapping

	mapping = {}

	d, n, m = input[0], input[1], input[2]

	S, K = input[3:3+n-1], input[3+n-1:]

	S = sorted(S)

	S = [S[-1]-d, 0] + S + [d]

	sum = 0

	for k in K:

		low, high = find(S, k, 0, len(S))

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

	print(sum)



while (True):

	d = int(input())

	if d == 0: break

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

	input = [d, n, m]

	for i in range(n-1+m):

		next_int = int(input())

		input.append(next_int)

	print_sum(input)
def find(l, e, start, end):

	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])

		return find(l, e, start, mid)

	elif (l[mid] < e):

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

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

		return find(l, e, mid, end)



def print_sum(input):

	d, n, m = input[0], input[1], input[2]

	S, K = input[3:3+n-1], input[3+n-1:]

	S = sorted(S)

	S = [S[-1]-d, 0] + S + [d]

	sum = 0

	for k in K:

		low, high = find(S, k, 0, len(S))

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

	print(sum)



while (True):

	d = int(input())

	if d == 0: break

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

	input = [d, n, m]

	for i in range(n-1+m):

		next_int = int(input())

		input.append(next_int)

	print_sum(input)
mapping = {}


def find(l, e, start, end):
    global mapping
    if e in mapping:
        return mapping[e]
    mid = (start + end) // 2
    if l[mid] == e:
        mapping[e] = (e, e)
        return mapping[e]
    elif l[mid] > e:
        if l[mid - 1] < e:
            mapping[e] = (l[mid - 1], l[mid])
            return mapping[e]
        return find(l, e, start, mid)
    elif l[mid] < e:
        if l[mid + 1] > e:
            mapping[e] = (l[mid], l[mid + 1])
            return mapping[e]
        return find(l, e, mid, end)


def print_sum(input):
    global mapping
    mapping = {}
    d, n, m = input[0], input[1], input[2]
    S, K = input[3 : 3 + n - 1], input[3 + n - 1 :]
    S = sorted(S)
    S = [S[-1] - d, 0] + S + [d]
    sum = 0
    for k in K:
        low, high = find(S, k, 0, len(S))
        sum += min(k - low, high - k)
    print(sum)


while True:
    d = int(input())
    if d == 0:
        break
    n, m = int(input()), int(input())
    input = [d, n, m]
    for i in range(n - 1 + m):
        next_int = int(input())
        input.append(next_int)
    print_sum(input)

def find(l, e, start, end):
    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])
        return find(l, e, start, mid)
    elif l[mid] < e:
        if l[mid + 1] > e:
            return (l[mid], l[mid + 1])
        return find(l, e, mid, end)


def print_sum(input):
    d, n, m = input[0], input[1], input[2]
    S, K = input[3 : 3 + n - 1], input[3 + n - 1 :]
    S = sorted(S)
    S = [S[-1] - d, 0] + S + [d]
    sum = 0
    for k in K:
        low, high = find(S, k, 0, len(S))
        sum += min(k - low, high - k)
    print(sum)


while True:
    d = int(input())
    if d == 0:
        break
    n, m = int(input()), int(input())
    input = [d, n, m]
    for i in range(n - 1 + m):
        next_int = int(input())
        input.append(next_int)
    print_sum(input)

-mapping = {} - - -    global mapping -    if e in mapping: -        return mapping[e] -        mapping[e] = (e, e) -        return mapping[e] +        return (e, e) -            mapping[e] = (l[mid - 1], l[mid]) -            return mapping[e] +            return (l[mid - 1], l[mid]) -            mapping[e] = (l[mid], l[mid + 1]) -            return mapping[e] +            return (l[mid], l[mid + 1]) -    global mapping -    mapping = {}