import collections

def fast_one(a, b, k) :
	n = len(a)
	m = len(b)
	
	used = [collections.deque() for i in range(n + 1)]
	
	closest = 0
	for i in range(m) :
		while closest + 1 < n and abs(b[i] - a[closest]) >= abs(b[i] - a[closest + 1]) : closest += 1
		if len(used[closest]) == k :
			r = closest
			l = closest
			while l and len(used[l - 1]) == k : l -= 1
			while r + 1 < n and len(used[r + 1]) == k : r += 1
			r += 1
			used[r].append(i)
			
			shift_delta = 0
			for j in range(l, r + 1) : shift_delta += abs(a[j - 1] - b[used[j][0]]) - abs(a[j] - b[used[j][0]])
			if shift_delta < 0 :
				for j in range(l, r + 1) :
					used[j - 1].append(used[j][0])
					used[j].popleft()
		else : used[closest].append(i)
	
	res = 0
	for i in range(n) :
		for j in used[i] : res += abs(a[i] - b[j])
	
	return res

def fast(a, b) :
	a.sort()
	b.sort()
	a = [-1000000000000000000] + a + [1000000000000000000]
	
	res = []
	for i in range(1, m + 1) : res.append(fast_one(a, b, i))
	return res

m, n = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

res = fast(b, a)
for i in res : print(i)