# AOJ 0539: Pizza

# Python3 2018.7.1 bal4u



import bisect



while True:

	d = int(eval(input()))

	if d == 0: break

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

	p = [0] + [int(eval(input())) for i in range(n-1)] + [d]

	p.sort()

	ans = 0

	for i in range(m):

		k = int(eval(input()))

		if k > 0:

			t = bisect.bisect_left(p, k)

			ans += min(k-p[t-1], p[t]-k)

	print(ans)

# AOJ 0539: Pizza

# Python3 2018.7.1 bal4u



import sys

from sys import stdin

input = stdin.readline

import bisect



while True:

	d = int(eval(input()))

	if d == 0: break

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

	p = [0] + [int(eval(input())) for i in range(n-1)] + [d]

	p.sort()

	ans = 0

	for i in range(m):

		k = int(eval(input()))

		if k > 0:

			t = bisect.bisect_left(p, k)

			ans += min(k-p[t-1], p[t]-k)

	print(ans)

# AOJ 0539: Pizza
# Python3 2018.7.1 bal4u
import bisect

while True:
    d = int(eval(input()))
    if d == 0:
        break
    n, m = int(eval(input())), int(eval(input()))
    p = [0] + [int(eval(input())) for i in range(n - 1)] + [d]
    p.sort()
    ans = 0
    for i in range(m):
        k = int(eval(input()))
        if k > 0:
            t = bisect.bisect_left(p, k)
            ans += min(k - p[t - 1], p[t] - k)
    print(ans)

# AOJ 0539: Pizza
# Python3 2018.7.1 bal4u
import sys
from sys import stdin

input = stdin.readline
import bisect

while True:
    d = int(eval(input()))
    if d == 0:
        break
    n, m = int(eval(input())), int(eval(input()))
    p = [0] + [int(eval(input())) for i in range(n - 1)] + [d]
    p.sort()
    ans = 0
    for i in range(m):
        k = int(eval(input()))
        if k > 0:
            t = bisect.bisect_left(p, k)
            ans += min(k - p[t - 1], p[t] - k)
    print(ans)

+import sys +from sys import stdin + +input = stdin.readline