You are given two positive integer sequences $a_1, \ldots, a_n$ and $b_1, \ldots, b_m$. For each $j = 1, \ldots, m$ find the greatest common divisor of $a_1 + b_j, \ldots, a_n + b_j$.


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \leq n, m \leq 2 \cdot 10^5$).

The second line contains $n$ integers $a_1, \ldots, a_n$ ($1 \leq a_i \leq 10^{18})$.

The third line contains $m$ integers $b_1, \ldots, b_m$ ($1 \leq b_j \leq 10^{18})$.


-----Output-----

Print $m$ integers. The $j$-th of them should be equal to GCD$(a_1 + b_j, \ldots, a_n + b_j)$.


-----Examples-----

Input
4 4
1 25 121 169
1 2 7 23
Output
2 3 8 24


-----Note-----

None

Difficulty: MEDIUM_HARD
Tags: Number theory

Mathematics

Starter code:

Solutions:
import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
start_time = time.time()

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 998244353

def solve():
	(N, M) = getInts()
	A = getInts()
	B = getInts()
	ans = []
	if N == 1:
		for j in range(M):
			ans.append(B[j] + A[0])
		print(*ans)
		return
	A.sort()
	D = [A[j + 1] - A[j] for j in range(N - 1)]
	curr = D[0]
	for i in range(1, N - 1):
		curr = math.gcd(curr, D[i])
	for j in range(M):
		ans.append(math.gcd(curr, B[j] + A[0]))
	print(*ans)
	return
solve()


import math
(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a1 = a[0]
without_a1 = [a_i - a[0] for a_i in a[1:]]
common_gcd = without_a1[0] if without_a1 else 0
for a_i in without_a1[1:]:
	common_gcd = math.gcd(common_gcd, a_i)
print(*[math.gcd(common_gcd, b_i + a1) for b_i in b], sep=' ')


import sys
input = sys.stdin.readline
from math import gcd

def main():
	(n, m) = map(int, input().split())
	alst = list(map(int, input().split()))
	blst = list(map(int, input().split()))
	g = 0
	for i in range(n - 1):
		g = gcd(g, alst[i + 1] - alst[i])
	a = alst[0]
	ans = [gcd(g, b + a) for b in blst]
	print(*ans)
for _ in range(1):
	main()


import math
(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
o = 0
for i in range(1, n):
	o = math.gcd(o, a[i] - a[0])
for i in b:
	t = math.gcd(i + a[0], o)
	print(t, end=' ')
print('')


from math import gcd
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
arr.sort()
g = 0
if n > 1:
	g = arr[1] - arr[0]
for i in range(2, n):
	g = gcd(arr[i] - arr[0], g)
for i in range(m):
	print(gcd(brr[i] + arr[0], g), end=' ')


import math
(l, m) = [int(n) for n in input().split()]
series1 = [int(n) for n in input().split()]
series2 = [int(n) for n in input().split()]
result = []
if len(series1) == 1:
	for n in series2:
		result.append(str(n + series1[0]))
else:
	series1.sort()
	small = series1[0]
	series1 = [n - small for n in series1]
	gcd = series1[1]
	for i in range(2, len(series1)):
		gcd = math.gcd(gcd, series1[i])
	result = []
	for n in series2:
		result.append(str(math.gcd(gcd, small + n)))
print(' '.join(result))


import sys
input = sys.stdin.readline

def hcfnaive(a, b):
	if b == 0:
		return a
	else:
		return hcfnaive(b, a % b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	for i in range(m):
		print(a[0] + b[i], end=' ')
else:
	g = abs(a[0] - a[1])
	for i in range(1, n):
		g = hcfnaive(g, abs(a[i] - a[i - 1]))
	for i in range(m):
		print(hcfnaive(g, a[0] + b[i]), end=' ')


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def solution():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	if len(a) == 1:
		for j in range(m):
			print(a[0] + b[j], end=' ')
		print()
	else:
		if len(a) == 2:
			ans = a[1] - a[0]
		else:
			ans = gcd(a[1] - a[0], a[2] - a[0])
			for i in range(3, n):
				ans = gcd(ans, a[i] - a[0])
		for j in range(m):
			print(gcd(a[0] + b[j], ans), end=' ')
		print()
solution()


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
if n == 1:
	for j in range(m):
		ans.append(a[0] + b[j])
else:
	for i in range(n - 1):
		if i == 0:
			max_gcd = abs(a[i + 1] - a[i])
		else:
			max_gcd = gcd(max_gcd, abs(a[i + 1] - a[i]))
	for j in range(m):
		ans.append(gcd(max_gcd, a[0] + b[j]))
print(*ans)


import sys, math, itertools, collections, copy
input = sys.stdin.readline

def gcdfun(a: int, b: int) -> int:
	if b == 0:
		return a
	return gcdfun(b, a % b)
(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
b = [int(x) for x in input().split()]
if n == 1:
	for j in range(m):
		print(b[j] + a[0])
	exit()
diff = [0]
gcd = float('INF')
for i in range(1, n):
	diff.append(a[i] - a[i - 1])
	if i > 2:
		gcd = gcdfun(gcd, gcdfun(diff[-1], diff[-2]))
	elif i > 1:
		gcd = min(gcd, gcdfun(diff[-1], diff[-2]))
for j in range(m):
	print(gcdfun(gcd, b[j] + a[0]), end=' ')


import sys
import math
import collections
from copy import copy
from math import gcd
input = sys.stdin.readline

def algo(a, b):
	x = min(a)
	k = 0
	for i in a:
		k = gcd(k, i - x)
	ans = []
	for i in b:
		ans.append(gcd(k, x + i))
	print(*ans)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
algo(a, b)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd

def main():
	(n, m) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = list(map(int, input().split()))
	if n == 1:
		print(*[a[0] + b[s] for s in range(m)])
	else:
		num = a[1] - a[0]
		for s in range(1, n):
			num = gcd(num, a[s] - a[0])
		ans = []
		for s in range(m):
			ans.append(gcd(num, b[s] + a[0]))
		print(*ans)
main()


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
G = 0
for i in range(n):
	G = gcd(G, A[i] - A[0])
A.sort()
for i in range(m):
	print(gcd(G, A[0] + B[i]), end=' ')


(n, m) = list(map(int, input().split()))
alst = list(map(int, input().split()))
blst = list(map(int, input().split()))
alst = set(alst)
alst = list(alst)
alst = sorted(alst)
n = len(alst)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
if n == 1:
	for x in blst:
		gc = gcd(x + alst[0], 0)
		print(gc, end=' ')
	print()
else:
	gc = 0
	for x in alst[1:]:
		gc = gcd(x - alst[0], gc)
	for x in blst:
		print(gcd(alst[0] + x, gc), end=' ')
	print()


from collections import defaultdict, Counter
import sys
import bisect
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
a = get_array()
b = get_array()
G = 0
for i in range(1, n):
	G = math.gcd(G, a[i] - a[0])
for i in range(m):
	print(math.gcd(a[0] + b[i], G), end=' ')


from math import gcd
(_, a, g) = (input(), list(map(int, input().split())), 0)
for v in a[1:]:
	g = gcd(g, v - a[0])
print(*[gcd(g, v + a[0]) for v in map(int, input().split())])


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
acc = 0
for i in range(n - 1):
	acc = gcd(acc, a[i + 1] - a[i])
print(*[gcd(acc, a[0] + e) for e in b])


from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import Queue, PriorityQueue
from heapq import heapify, heappop, heappush
from statistics import median
from math import gcd, sqrt, floor, factorial, ceil, log2, log10
import fractions
import copy
from copy import deepcopy
import sys
sys.setrecursionlimit(10 ** 7)
import math
import os
import bisect
import collections
mod = pow(10, 9) + 7
import random
from random import random, randint, randrange

def ncr(n, r, p=mod):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
inf = float('inf')
adj = defaultdict(set)
visited = defaultdict(int)

def addedge(a, b):
	adj[a].add(b)
	adj[b].add(a)

def bfs(v):
	q = Queue()
	q.put(v)
	visited[v] = 1
	while q.qsize() > 0:
		s = q.get_nowait()
		print(s)
		for i in adj[s]:
			if visited[i] == 0:
				q.put(i)
				visited[i] = 1

def dfs(v, visited):
	if visited[v] == 1:
		return
	visited[v] = 1
	print(v)
	for i in adj[v]:
		dfs(i, visited)

def reverse_bisect_right(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x > a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

def reverse_bisect_left(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x >= a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

class MaxHeap:

	def __init__(self, maxsize):
		self.maxsize = maxsize
		self.size = 0
		self.Heap = [0] * (self.maxsize + 1)
		self.Heap[0] = sys.maxsize
		self.FRONT = 1

	def parent(self, pos):
		return pos // 2

	def leftChild(self, pos):
		return 2 * pos

	def rightChild(self, pos):
		return 2 * pos + 1

	def isLeaf(self, pos):
		if pos >= self.size // 2 and pos <= self.size:
			return True
		return False

	def swap(self, fpos, spos):
		(self.Heap[fpos], self.Heap[spos]) = (self.Heap[spos], self.Heap[fpos])

	def maxHeapify(self, pos):
		if not self.isLeaf(pos):
			if self.Heap[pos] < self.Heap[self.leftChild(pos)] or self.Heap[pos] < self.Heap[self.rightChild(pos)]:
				if self.Heap[self.leftChild(pos)] > self.Heap[self.rightChild(pos)]:
					self.swap(pos, self.leftChild(pos))
					self.maxHeapify(self.leftChild(pos))
				else:
					self.swap(pos, self.rightChild(pos))
					self.maxHeapify(self.rightChild(pos))

	def insert(self, element):
		if self.size >= self.maxsize:
			return
		self.size += 1
		self.Heap[self.size] = element
		current = self.size
		while self.Heap[current] > self.Heap[self.parent(current)]:
			self.swap(current, self.parent(current))
			current = self.parent(current)

	def Print(self):
		for i in range(1, self.size // 2 + 1):
			print(' PARENT : ' + str(self.Heap[i]) + ' LEFT CHILD : ' + str(self.Heap[2 * i]) + ' RIGHT CHILD : ' + str(self.Heap[2 * i + 1]))

	def extractMax(self):
		popped = self.Heap[self.FRONT]
		self.Heap[self.FRONT] = self.Heap[self.size]
		self.size -= 1
		self.maxHeapify(self.FRONT)
		return popped

def get_list():
	return list(map(int, input().split()))

def get_str_list_in_int():
	return [int(i) for i in list(input())]

def get_str_list():
	return list(input())

def get_map():
	return map(int, input().split())

def input_int():
	return int(input())

def matrix(a, b):
	return [[0 for i in range(b)] for j in range(a)]

def swap(a, b):
	return (b, a)

def find_gcd(l):
	a = l[0]
	for i in range(len(l)):
		a = gcd(a, l[i])
	return a

def is_prime(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return 0
	return 1

def prime_factors(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return [i] + prime_factors(n // i)
	return [n]
nc = 'NO'
yc = 'YES'
ns = 'No'
ys = 'Yes'
t = 1
for i in range(t):
	(n, m) = get_map()
	a = get_list()
	b = get_list()
	if n == 1:
		print(*[a[0] + i for i in b])
		continue
	gcda = abs(a[1] - a[0])
	for i in range(n):
		gcda = gcd(abs(a[i] - a[0]), gcda)
	ans = [gcd(gcda, a[0] + b[i]) for i in range(m)]
	print(*ans)


import sys, os
from math import sqrt, gcd, ceil, log, floor
from math import factorial as fact
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
from itertools import permutations
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 10 ** 9 + 7

def main():
	(n, m) = read()
	a = read()
	b = read()
	a.sort()
	gc = 0
	for i in range(n - 1):
		gc = gcd(gc, a[i + 1] - a[i])
	ans = []
	for i in b:
		ans.append(gcd(gc, a[0] + i))
	print(*ans)
main()


import sys
input = sys.stdin.readline

def gcd(a, b):
	if b == 0:
		return a
	if a % b == 0:
		return b
	return gcd(b, a % b)
l = input().split()
n = int(l[0])
m = int(l[1])
l = input().split()
li = [int(i) for i in l]
z = 0
li.sort()
for i in range(1, n):
	z = gcd(z, li[i] - li[i - 1])
b = input().split()
bi = [int(i) for i in b]
for i in bi:
	print(gcd(z, i + li[-1]), end=' ')


import math

def main():
	(n, m) = (int(x) for x in input().split())
	l1 = list(set([int(x) for x in input().split()]))
	l2 = [int(x) for x in input().split()]
	if len(l1) == 1:
		xx = [str(l1[0] + x) for x in l2]
		print(*xx)
		exit()
	common_gcd = l1[1] - l1[0]
	for i in range(1, len(l1)):
		common_gcd = math.gcd(common_gcd, l1[i] - l1[0])
	print(*[math.gcd(common_gcd, l1[0] + i) for i in l2])
main()


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
output = []

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
res = 0
for index in range(1, n):
	res = gcd(abs(a[index] - a[0]), res)
for index in range(0, m):
	output += [gcd(res, a[0] + b[index])]
print(' '.join(map(str, output)))


from sys import stdin
from collections import defaultdict
import heapq
import math
from functools import reduce
(n, m) = map(int, stdin.buffer.readline().split())
a = list(map(int, stdin.buffer.readline().split()))
b = list(map(int, stdin.buffer.readline().split()))
delta = []
mn = min(a)
for x in a:
	if x != mn:
		delta.append(x - mn)
if len(delta):
	biggest_gcd = reduce(math.gcd, delta)
	lst = [str(math.gcd(el + mn, biggest_gcd)) for el in b]
else:
	lst = [str(el + mn) for el in b]
print(' '.join(lst))


import sys
from collections import *
import math
import bisect

def input():
	return sys.stdin.readline()

def gcd(x, y):
	if x == 0:
		return y
	else:
		return gcd(y % x, x)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	for i in range(m):
		print(a[0] + b[i], end=' ')
	exit()
elif n == 2:
	g = a[1] - a[0]
else:
	g = a[1] - a[0]
	for i in range(1, n):
		g = gcd(a[i] - a[0], g)
for i in range(m):
	print(gcd(a[0] + b[i], g), end=' ')


(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
t = 0
for i in range(N):
	t = gcd(t, A[i] - A[0])
ans = []
for i in range(M):
	ans.append(gcd(t, A[0] + B[i]))
print(' '.join((str(i) for i in ans)))


from math import gcd
(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
a.sort()
ans = []
if n > 1:
	for i in range(1, n):
		a[i] -= a[0]
	g = a[1]
	for i in range(1, n):
		g = gcd(g, a[i])
	for x in b:
		ans.append(gcd(a[0] + x, g))
else:
	for x in b:
		ans.append(a[0] + x)
print(*ans)


import math

def row_gcd(n_arr, m_arr, n, m):
	ans = 0
	for i in range(1, n):
		ans = math.gcd(ans, n_arr[i] - n_arr[i - 1])
	for i in range(0, m):
		print(math.gcd(ans, n_arr[0] + m_arr[i]), end=' ')
(n, m) = map(int, input().split())
n_arr = list(map(int, input().split()))
m_arr = list(map(int, input().split()))
row_gcd(n_arr, m_arr, n, m)


import sys
input = sys.stdin.readline
(n, m) = list(map(int, input().split()))
from math import gcd
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if len(a) == 1:
	x = [a[0] + b[i] for i in range(0, len(b))]
	print(*x)
else:
	diff = []
	for i in range(1, len(a)):
		diff.append(a[i] - a[i - 1])
	ans = diff[0]
	for i in range(1, len(diff)):
		ans = gcd(ans, diff[i])
	x = [gcd(ans, a[0] + b[i]) for i in range(0, len(b))]
	print(*x)


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a.sort()

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
tmp = 0
for i in range(1, len(a)):
	tmp = gcd(tmp, a[i] - a[i - 1])
ret = []
for i in range(len(b)):
	ret.append(gcd(tmp, a[-1] + b[i]))
print(*ret)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lgcd(a):
	res = a[0]
	for i in range(1, len(a)):
		res = gcd(res, a[i])
	return res
(n, m) = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
if n == 1:
	ans = [b[j] + a[0] for j in range(m)]
else:
	A = lgcd([a[i + 1] - a[i] for i in range(n - 1)])
	ans = [gcd(b[j] + a[0], A) for j in range(m)]
print(*ans)


import sys
input = sys.stdin.readline
l = input().split()
n = int(l[0])
m = int(l[1])
arr1 = [0] * n
arr2 = [0] * m

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
l = input().split()
for i in range(n):
	arr1[i] = int(l[i])
arr1.sort()
l = input().split()
for i in range(m):
	arr2[i] = int(l[i])
g = 0
for i in range(n):
	g = gcd(arr1[i] - arr1[0], g)
for i in range(m):
	ans = gcd(arr1[0] + arr2[i], g)
	print(str(ans) + ' ', end='')


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1

def input():
	return sys.stdin.readline().strip()
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
(n, m) = ilele()
A = alele()
B = alele()

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
if n == 1:
	for i in range(m):
		print(A[0] + B[i], end=' ')
else:
	A.sort()
	g = A[1] - A[0]
	for i in range(2, n):
		g = gcd(g, A[i] - A[i - 1])
	for i in range(m):
		print(gcd(A[0] + B[i], g), end=' ')


from math import *
(n, m) = map(int, input().split())
q = list(map(int, input().split()))
q.sort()
g = 0
for i in range(1, n):
	g = gcd(g, q[i] - q[0])
for i in map(int, input().split()):
	print(gcd(g, i + q[0]), end=' ')


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
g = 0
for i in range(n):
	g = math.gcd(g, a[i] - a[0])
for i in range(m):
	print(math.gcd(a[0] + b[i], g), end=' ')
print()


import math
from functools import reduce
input()
n = list(map(int, list(input().split())))
m = list(map(int, list(input().split())))
ans = []
alllists = []
for i in range(1, len(n)):
	alllists.append(n[i] - n[0])
ggcd = reduce(math.gcd, alllists, 0)
for b in m:
	ans.append(math.gcd(n[0] + b, ggcd))
print(*ans)


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def arraygcd(l):
	num1 = l[0]
	num2 = l[1]
	gcd = find_gcd(num1, num2)
	for i in range(2, len(l)):
		gcd = find_gcd(gcd, l[i])
	return gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
a.sort()
for i in range(1, n):
	c.append(a[i] - a[0])
g = 0
if len(c) > 0:
	g = arraygcd(c)
ans = []
for i in range(m):
	ans.append(find_gcd(a[0] + b[i], g))
for i in ans:
	print(i, end=' ')


from math import gcd
from sys import stdin
input = stdin.readline

def row(a, b):
	if len(a) == 1:
		for i in b:
			print(a[0] + i, end=' ')
		return ''
	base = list(map(lambda s: s - a[0], a[1:]))
	curr = gcd(base[0], base[1])
	for i in base[2:]:
		curr = gcd(curr, i)
	for i in b:
		print(gcd(i + a[0], curr), end=' ')
	return ''
a = input()
ls1 = list(map(int, input().strip().split()))
ls2 = list(map(int, input().strip().split()))
print(row(ls1, ls2))


import math
(n, m) = list(map(int, input().split()))
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
gcd = 0
for i in range(1, n):
	gcd = math.gcd(gcd, abs(l1[i] - l1[0]))
for i in range(m):
	l2[i] = math.gcd(l1[0] + l2[i], gcd)
print(*l2)


from math import gcd
from sys import stdin, stdout
(a_count, b_count) = list(map(int, stdin.readline().split(' ')))
a = list(map(int, stdin.readline().split(' ')))
b = list(map(int, stdin.readline().split(' ')))
if a_count == 1:
	x = a[0]
	for num in b:
		stdout.write(f'{a[0] + num} ')
else:
	x = a[1] - a[0]
	for i in range(1, a_count):
		x = gcd(x, a[i] - a[i - 1])
		if x == 1:
			break
	for num in b:
		stdout.write(f'{gcd(x, a[0] + num)} ')


import math
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
if n == 1:
	for j in range(m):
		print(arr[0] + brr[j], end=' ')
		print()
else:
	ans = arr[1] - arr[0]
	for i in range(2, n):
		ans = math.gcd(ans, arr[i] - arr[i - 1])
	for j in range(m):
		print(math.gcd(arr[0] + brr[j], ans), end=' ')
	print()


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
_gcd = 0
for i in range(1, n):
	_gcd = gcd(a[i] - a[0], _gcd)
ans = []
for j in range(m):
	ans.append(str(gcd(a[0] + b[j], _gcd)))
print(' '.join(ans))


import sys
import math
import collections
import bisect
import string

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	(n, m) = get_ints()
	arr1 = get_list()
	arr2 = get_list()
	a = arr1[0]
	temp = []
	for i in range(1, n):
		temp.append(arr1[i] - a)
	if len(temp) == 0:
		g = 0
	elif len(temp) == 1:
		g = temp[0]
	else:
		g = math.gcd(temp[0], temp[1])
		for i in range(2, len(temp)):
			g = math.gcd(g, temp[i])
	ans = []
	for i in arr2:
		val = math.gcd(a + i, g)
		ans.append(val)
	print(*ans)


from sys import stdin, stdout
import math

def main():
	(n, m) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	min_a = min(a)
	gcd_a = -1
	for x in a:
		if x == min_a:
			continue
		if gcd_a == -1:
			gcd_a = x - min_a
			continue
		gcd_a = math.gcd(gcd_a, x - min_a)
		if gcd_a == 1:
			break
	ans = []
	for y in b:
		if gcd_a == -1:
			ans.append(str(a[0] + y))
		else:
			ans.append(str(math.gcd(gcd_a, min_a + y)))
	print(' '.join(ans))
main()


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(1):
	ll = [int(x) for x in input().split()]
	la = ll[0]
	lb = ll[1]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	final = []
	a.sort()
	g = 0
	for i in range(1, la):
		g = gcd(g, a[i] - a[i - 1])
	for i in range(lb):
		print(gcd(g, a[0] + b[i]), end=' ')


import sys, math
input = sys.stdin.readline
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ANS = []
GCD = 0
for i in range(1, N):
	GCD = math.gcd(A[i] - A[0], GCD)
for i in B:
	ANS.append(math.gcd(A[0] + i, GCD))
print(*ANS)


from math import *
ans = 0
s = []
t = []
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1, n):
	ans = gcd(ans, abs(a[0] - a[i]))
for j in range(m):
	print(gcd(ans, a[0] + b[j]), end=' ')
print()


from sys import stdin
from math import gcd
input = stdin.readline
(n, m) = map(int, input().split())
lst_n = list(map(int, input().split()))
lst_m = list(map(int, input().split()))
x = lst_n[0]
lst_n = [i - x for i in lst_n]
lst_n[0] = x
(g, k, arr) = (0, 0, [0] * m)
for i in range(1, n):
	g = gcd(g, lst_n[i])
while k < m:
	arr[k] = gcd(g, x + lst_m[k])
	k += 1
print(*arr)


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	from math import gcd
	input = sys.stdin.readline
	(N, M) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	AA = []
	for i in range(N - 1):
		AA.append(abs(A[i] - A[i - 1]))
	g = 0
	for a in AA:
		g = gcd(g, a)
	ans = []
	for j in range(M):
		ans.append(gcd(g, A[0] + B[j]))
	print(*ans)
main()


import math
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
if n == 1:
	for i in range(m):
		print(arr[0] + brr[i])
	exit()
l = arr[1] - arr[0]
for i in range(2, n):
	l = math.gcd(l, arr[i] - arr[i - 1])
for i in range(m):
	print(math.gcd(arr[0] + brr[i], l), end=' ')


import math as mt
(m, n) = map(int, input().split())
arr = list(map(int, input().strip().split()))[:m]
brr = list(map(int, input().strip().split()))[:n]
l = []
arr.sort()
crr = []
if m > 1:
	for i in range(1, m):
		crr.append(arr[i] - arr[i - 1])
	y = crr[0]
	for i in range(1, m - 1):
		y = mt.gcd(y, crr[i])
	for i in range(0, n):
		x = mt.gcd(arr[0] + brr[i], y)
		l.append(x)
else:
	for i in range(0, n):
		x = arr[0] + brr[i]
		l.append(x)
print(*l, sep=' ')


from math import gcd as __gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
gcd = 0
for i in range(1, n):
	gcd = __gcd(gcd, a[i] - a[0])
for i in range(m):
	print(__gcd(gcd, a[0] + b[i]), end=' ')


import math
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if n >= 2:
	C = sorted(A)
	mi_gcd = C[1] - C[0]
	for a in range(1, n - 1):
		mi_gcd = math.gcd(mi_gcd, C[a + 1] - C[a])
	for a in range(m):
		f = C[0] + B[a]
		print(math.gcd(f, mi_gcd), end=' ')
	print()
else:
	ans = []
	for i in range(m):
		ans.append(A[0] + B[i])
	print(*ans)


from sys import stdin

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
mini = min(a)
prevg = 0
for i in a:
	prevg = gcd(i - mini, prevg)
for i in b:
	print(gcd(prevg, mini + i), end=' ')


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
out = 0
for i in range(1, n):
	out = math.gcd(out, abs(a[0] - a[i]))
print(*[math.gcd(out, a[0] + b[j]) for j in range(m)])


import math

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n >= 2:
		for i in range(n - 1, 0, -1):
			a[i] -= a[i - 1]
		base_ans = abs(a[1])
		for i in range(2, n):
			base_ans = math.gcd(base_ans, abs(a[i]))
		print(*[math.gcd(a[0] + x, base_ans) for x in b])
	else:
		print(*[a[0] + x for x in b])
main()


import math
import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
ans = 0
for i in range(1, n):
	ans = math.gcd(ans, abs(l1[0] - l1[i]))
for i in range(m):
	print(math.gcd(l1[0] + l2[i], ans), end=' ')


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
gc = 0
for i in a[1:]:
	gc = gcd(gc, i - a[0])
for i in range(m):
	print(gcd(gc, a[0] + b[i]), end=' ')


import sys
import math
input = sys.stdin.readline
(n, m) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
G = 0
for i in range(1, n):
	G = math.gcd(G, a[i] - a[0])
c = [math.gcd(a[0] + x, G) for x in b]
print(*c)


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

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
temp = 0
for i in range(1, len(a)):
	temp = gcd(temp, abs(a[i] - a[i - 1]))
for i in range(len(b)):
	print(gcd(b[i] + a[0], temp), end=' ')


from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = list(set(a))
n = len(a)
ma = min(a)
s = 0
for i in range(n):
	if a[i] != ma:
		a[i] -= ma
		s = gcd(s, a[i])
for i in range(m):
	print(gcd(s, ma + b[i]), end=' ')


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

def gcd(x, y):
	while x != 0 and y != 0:
		if x > y:
			(x, y) = (y, x)
		(x, y) = (y % x, x)
	return x + y
g = 0
for i in range(n - 1):
	g = gcd(g, a[i + 1] - a[i])
for x in b:
	print(gcd(g, x + a[0]), end=' ')


from math import gcd
(n, m) = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = [0] * m
if n == 1:
	for i in range(m):
		ans[i] = A[0] + B[i]
else:
	GCD = A[1] - A[0]
	for i in range(1, n):
		GCD = gcd(GCD, A[i] - A[0])
	for i in range(m):
		ans[i] = gcd(GCD, B[i] + A[0])
print(*ans)


def read_ints():
	return [int(x) for x in input().split()]

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def calc():
	(n, m) = read_ints()
	a = read_ints()
	b = read_ints()
	a.sort()
	if n == 1:
		gcd_a = 0
	else:
		gcd_a = a[1] - a[0]
		for a_i in a[2:]:
			gcd_a = gcd(gcd_a, a_i - a[0])
	for b_i in b:
		print(gcd(a[0] + b_i, gcd_a), end=' ')

def main():
	calc()
main()


import sys
import math

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))
(n, m) = minput()
a = listinput()
b = listinput()
G = 0
for i in range(1, n):
	G = math.gcd(G, a[i] - a[0])
c = [math.gcd(a[0] + x, G) for x in b]
for i in b:
	print(math.gcd(a[0] + i, G), end=' ')


import math

def solve():
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	ans = 0
	for i in range(1, n):
		ans = math.gcd(ans, abs(l[i] - l[0]))
	for j in range(m):
		print(math.gcd(ans, l[0] + l1[j]), end=' ')
	print()
t = 1
for i in range(t):
	solve()


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in b:
	ans = a[0] + i
	if len(a) >= 2:
		ans = gcd(a[0] + i, a[1] + i)
	if len(a) > 2:
		ans = gcd(ans, a[(len(a) - 1) // 4] + i)
		ans = gcd(ans, a[(len(a) - 1) // 2] + i)
		ans = gcd(ans, a[(len(a) - 1) * 3 // 4] + i)
		ans = gcd(ans, a[len(a) - 1] + i)
	print(ans, end=' ')


import sys, math
input = sys.stdin.readline
INF = int(1000000000.0) + 7
MOD = 998244353

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	g = 0
	for i in range(n - 1):
		g = math.gcd(g, abs(a[i + 1] - a[i]))
	ans = 0
	for i in range(m):
		print(math.gcd(g, a[0] + b[i]), end=' ')
	print()
t = 1
for i in range(1, t + 1):
	solve()


from math import gcd
from functools import reduce

def gcdOfList(L):
	x = reduce(gcd, L)
	return x
[n, m] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
a = sorted(a)
out = []
if len(a) == 1:
	out = map(lambda x: x + a[0], b)
else:
	for j in range(1, n):
		a[j] = a[j] - a[0]
	first = a[0]
	rest = gcdOfList(a[1:])
	for j in range(m):
		out.append(gcd(first + b[j], rest))
print(' '.join(map(str, out)))


(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
result = []
d = {}

def gcd(s, t):
	if t == 0:
		return s
	return gcd(t, s % t)
if n == 1:
	val = 0
else:
	val = a[1] - a[0]
	for i in range(2, n):
		val = gcd(max(val, a[i] - a[0]), min(val, a[i] - a[0]))
for j in range(m):
	result.append(gcd(val, a[0] + b[j]))
print(' '.join((str(x) for x in result)))


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

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
g = 0
for i in range(1, n):
	g = gcd(g, a[i] - a[0])
for j in range(m):
	print(gcd(g, b[j] + a[0]))


(m, n) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
from functools import reduce
from math import gcd
if len(a) == 1:
	main = a[0]
	print(' '.join((str(a[0] + i) for i in b)))
else:
	m = [a[i] - a[0] for i in range(1, len(a))]
	main = reduce(lambda a, b: gcd(a, b), m)
	print(' '.join((str(i) for i in [gcd(main, i + a[0]) for i in b])))


import math as ma
(n, m) = map(int, input().split())
a = input().split()
b = input().split()
if n == 1:
	for B in b:
		print(int(B) + int(a[0]), end=' ')
	print()
else:
	x = n - 1
	y = int(a[1]) - int(a[0])
	for i in range(x):
		y = ma.gcd(int(a[i + 1]) - int(a[i]), y)
	for i in range(m):
		print(ma.gcd(y, int(a[0]) + int(b[i])), end=' ')


import math
import sys
import bisect
from heapq import heapify, heappop, heappush
from itertools import *
from collections import deque, OrderedDict
from pprint import pprint
sys.setrecursionlimit(10 ** 6)
II = lambda : sys.stdin.readline()
inp = lambda : int(II())
inpm = lambda : map(int, II().split())
inpl = lambda : list(inpm())
(WHITE, GREY, BLACK, RED) = (0, 1, 2, 3)
EPS = 1e-09
INF = int(1e+18)
MOD = int(1000000000.0) + 7
N = 2000009

def nod(a, b):
	while a > 0:
		(a, b) = (b % a, a)
	return b

def solve():
	(n, m) = inpm()
	a = inpl()
	b = inpl()
	a.sort()
	if n == 1:
		for i in range(m):
			print(a[0] + b[i], end=' ')
	else:
		NOD = a[1] - a[0]
		for i in range(1, n):
			NOD = nod(NOD, a[i] - a[i - 1])
		for i in range(m):
			res = nod(a[0] + b[i], NOD)
			print(res, end=' ')
	print()

def main():
	t = 1
	for i in range(t):
		solve()
main()


from math import gcd as g
I = lambda : list(map(int, input().split()))
(n, m) = I()
(x, a) = (0, I())
b = I()
for i in range(1, n):
	x = g(x, abs(a[0] - a[i]))
print(*[g(x, a[0] + b[j]) for j in range(m)])


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = a.copy()
a1.sort()
if n == 1:
	ans = []
	for i in range(m):
		ans.append(a[0] + b[i])
	print(*ans)
else:
	x = a[1] - a[0]
	for i in range(1, n):
		x = math.gcd(x, a[i] - a[0])
	ans = []
	for i in range(m):
		ans.append(math.gcd(a[0] + b[i], x))
	print(*ans)


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(n, m) = Neo()
A = Neo()
B = Neo()
A.sort()
for i in range(1, n):
	A[i] -= A[0]
if n == 1:
	for i in B:
		print(i + A[0], end=' ')
else:
	gcd = A[1]
	for i in range(1, n):
		gcd = math.gcd(gcd, A[i])
	for i in B:
		t = math.gcd(gcd, A[0] + i)
		print(t, end=' ')


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(n, m) = MI()
aa = LI()
bb = LI()
g = 0
for (a0, a1) in zip(aa, aa[1:]):
	g = gcd(g, abs(a0 - a1))
for b in bb:
	print(gcd(g, aa[0] + b))


from math import gcd

def gcd_list(a, n):
	while n != 1:
		c = gcd(a[-1], a[-2])
		a.pop()
		a.pop()
		a.append(c)
		n -= 1
	return a[0]
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = gcd_list([max(a[0] - a[j], a[j] - a[0]) for j in range(n)], n)
for i in range(m):
	print(gcd(d, a[0] + b[i]), end=' ')


from math import gcd
import sys, io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
g = 0
for i in range(n - 1):
	g = gcd(g, a[i] - a[i + 1])
out = []
for v in b:
	out.append(gcd(v + a[0], g))
print(' '.join(map(str, out)))


from math import gcd
Y = lambda : map(int, input().split())
(n, m) = Y()
a = [*Y()]
b = [*Y()]
o = []
if n < 2:
	for i in range(m):
		o.append(str(a[0] + b[i]))
else:
	g = a[1] - a[0]
	for i in range(2, n):
		g = gcd(g, a[i] - a[i - 1])
	for i in range(m):
		o.append(str(gcd(a[0] + b[i], g)))
print(' '.join(o))


import sys
from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
b = list(map(int, input().split()))
result = [0] * m
if n == 1:
	for i in range(m):
		result[i] = a[0] + b[i]
	print(*result, sep=' ')
	sys.exit(0)
g = a[1] - a[0]
for i in range(2, n):
	g = gcd(g, a[i] - a[0])
result = [0] * m
for i in range(m):
	result[i] = gcd(g, a[0] + b[i])
print(*result, sep=' ')


from math import gcd
from functools import reduce
(n, m) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
mina = min(a)
a.remove(mina)
gcda_ = reduce(gcd, [ai - mina for ai in a], 0)
answer = [gcd(gcda_, bi + mina) for bi in b]
print(*answer)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
import math
import copy
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mina = min(a)
ans = []
arry = []
dupVar = []
copya = copy.deepcopy(a)
copya.sort()
for i in range(n - 1):
	if copya[i + 1] - copya[i] != 0:
		arry.append(copya[i + 1] - copya[i])
	else:
		dupVar.append(copya[i + 1])
if len(arry) == 0:
	for i in range(m):
		ans.append(mina + b[i])
else:
	currMin = min(arry)
	for ele in arry:
		currMin = math.gcd(currMin, ele)
	for i in range(m):
		ans.append(math.gcd(mina + b[i], currMin))
print(' '.join([str(x) for x in ans]))


from collections import defaultdict, deque
import sys
import bisect
import math
input = sys.stdin.readline
mod = 1000000007
(n, m) = map(int, input().split())
a = [int(i) for i in input().split() if i != '\n']
b = [int(i) for i in input().split() if i != '\n']
ans = []
if n == 1:
	for i in range(m):
		ans.append(a[0] + b[i])
	print(*ans)
else:
	diff = abs(a[1] - a[0])
	gcd = diff
	for i in range(1, n - 1):
		gcd = math.gcd(gcd, abs(a[i] - a[i + 1]))
	for i in range(m):
		ans.append(math.gcd(a[i] + b[i], gcd))
	print(*ans)


from math import gcd
from functools import reduce
(n, m) = tuple(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
others_gcd = 0
if n > 1:
	a = [a[0]] + [a[i] - a[0] for i in range(1, n)]
	others_gcd = reduce(gcd, a[1:])
for i in range(m):
	print(gcd(a[0] + b[i], others_gcd), end=' ')


def gcd(x, y):
	if x == 0:
		return y
	return gcd(y % x, x)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
g = 0
for i in range(1, n):
	g = gcd(abs(a[i] - a[0]), g)
for j in range(m):
	print(gcd(a[0] + b[j], g), end=' ')


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import math
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
a.sort()
if n == 1:
	for i in range(m):
		ans.append(a[0] + b[i])
	print(' '.join((str(x) for x in ans)))
else:
	diff = []
	x = a[1] - a[0]
	for i in range(1, n):
		diff.append(a[i] - a[i - 1])
		if diff[-1] != 0:
			x = math.gcd(x, diff[-1])
	for i in range(m):
		ans.append(math.gcd(x, a[0] + b[i]))
	print(' '.join((str(x) for x in ans)))


from functools import reduce
import math
(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [0] + [a[i] - a[0] for i in range(1, n)]
g = reduce(math.gcd, c, 0)
for x in b:
	print(math.gcd(g, a[0] + x))


def computeGCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
Sizk = [int(x) for x in input().split()]
First = [int(x) for x in input().split()]
Second = [int(x) for x in input().split()]
First.sort()
base = 0
for j in range(1, Sizk[0]):
	base = computeGCD(base, First[j] - First[0])
for i in range(Sizk[1]):
	temp = computeGCD(First[0] + Second[i], base)
	print(temp, end=' ')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def S():
	return input().strip()

def print_list(l):
	print(' '.join(map(str, l)))
from functools import reduce
from math import gcd
(_, a) = (input(), RLL())
g = reduce(gcd, [v - a[0] for v in a[1:]], 0)
print_list((gcd(g, v + a[0]) for v in RL()))


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	for i in range(m):
		print(a[0] + b[i], end=' ')
	print()
else:
	temp = a[1] - a[0]
	for i in range(2, n):
		temp = gcd(temp, a[i] - a[i - 1])
	for j in range(m):
		print(gcd(temp, a[0] + b[j]), end=' ')
	print()


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
if n == 1:
	g = []
	for j in range(m):
		g.append(a[0] + b[j])
	print(' '.join(map(str, g)))
else:
	c = a[1] - a[0]
	for j in range(2, n):
		c = gcd(c, a[j] - a[0])
	g = []
	for j in range(m):
		g.append(gcd(c, b[j] + a[0]))
	print(' '.join(map(str, g)))


import io
import os
from collections import Counter, defaultdict, deque
from math import gcd

def solve(N, M, A, B):
	A.sort()
	A2 = []
	for (x, y) in zip(A, A[1:]):
		A2.append(y - x)
	g = 0
	for x in A2:
		g = gcd(g, x)
	ans = []
	for j in range(M):
		ans.append(gcd(A[0] + B[j], g))
	return ' '.join(map(str, ans))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = 1
for tc in range(1, TC + 1):
	(N, M) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	ans = solve(N, M, A, B)
	print(ans)


def gcd(a, b):
	if b == 0:
		return a
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = min(a)
a.pop(a.index(min(a)))
a.append(d)
c = 0
for i in range(n - 1):
	c = gcd(c, a[i] - a[-1])
d = []
for i in range(m):
	d.append(gcd(c, a[-1] + b[i]))
print(*d)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import sqrt, ceil, gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = a[0]
for i in range(n):
	a[i] -= t
ans = 0
ck = 0
for i in a:
	ck = gcd(ck, i)
for i in b:
	print(gcd(t + i, ck), end=' ')
print()


def op():
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	g = 0
	ans = []
	for i in range(1, n):
		a[i] = a[i] - a[0]
	for i in range(1, n):
		if a[i] != 0:
			g = gcd(a[i], g)
	for i in range(m):
		gg = gcd(a[0] + b[i], g)
		ans.append(abs(gg))
	print(*ans)

def gcd(a, b):
	while b != 0:
		temp = b
		b = a % b
		a = temp
	return a
op()


from sys import stdin
from math import gcd
input = stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
b = list(map(int, input().split()))
if n >= 2:
	g = a[1] - a[0]
	for i in range(2, n):
		if a[i] - a[0] != 0:
			g = gcd(g, a[i] - a[0])
	ans = []
	for i in range(m):
		ans.append(gcd(g, a[0] + b[i]))
	print(*ans)
else:
	ans = []
	for j in range(m):
		ans.append(a[0] + b[j])
	print(*ans)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
from math import gcd
GCD = 0
for i in range(1, n):
	GCD = gcd(A[i] - A[i - 1], GCD)
ANS = []
for j in range(m):
	ANS.append(gcd(GCD, A[0] + B[j]))
print(*ANS)


from functools import reduce
from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, n):
	a[i] -= a[0]
g = reduce(gcd, a[1:], 0)
b = list(map(int, input().split()))
for each in b:
	print(gcd(g, a[0] + each), end=' ')


def gcd_lst(lst):

	def gcd(x, y):
		while y:
			(x, y) = (y, x % y)
		return x
	if not lst:
		return None
	curr = lst[0]
	for i in range(1, len(lst)):
		curr = gcd(curr, lst[i])
	return curr

def main():
	nm = input()
	(n, m) = nm.split(' ')
	(n, m) = (int(n), int(m))
	as_str = input()
	a_arr = as_str.split(' ')
	a_arr = list(map(lambda x: int(x), a_arr))
	a_min = min(a_arr)
	a_arr_cpy = list(a_arr)
	a_arr_cpy.remove(a_min)
	a_gcd = gcd_lst(list(map(lambda x: x - a_min, a_arr_cpy)))
	bs_str = input()
	b_arr = bs_str.split(' ')
	b_arr = list(map(lambda x: int(x), b_arr))
	ans = []
	for b in b_arr:
		if a_gcd:
			ans.append(gcd_lst([a_min + b, a_gcd]))
		else:
			ans.append(a_min + b)
	ans = list(map(lambda x: str(x), ans))
	print(' '.join(ans))
main()


R = lambda : map(int, input().split())
(n, m) = R()
a = list(R())

def find(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def gcd(arr):
	r = find(abs(arr[1] - arr[0]), abs(arr[2] - arr[0]))
	for i in range(2, len(arr)):
		r = find(r, abs(arr[i] - arr[0]))
	return r
b = list(R())
if n > 2:
	g = gcd(a)
else:
	g = 0
for i in b:
	if n > 2:
		print(find(g, a[0] + i), end=' ')
	elif n == 2:
		print(find(a[0] + i, a[1] - a[0]), end=' ')
	else:
		print(a[0] + i, end=' ')
print()


import math
(a, b) = list(map(int, input().split()))
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
y = 0
l1.sort()
for i in range(1, a - 1):
	y = math.gcd(y, l1[i] - l1[i - 1])
for i in range(b):
	x = math.gcd(l1[0] + l2[i], y)
	print(x, end=' ')


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
(n, m) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
brr = [int(x) for x in input().split()]
first = arr[0]
gc = 0
for i in range(1, n):
	gc = gcd(gc, abs(arr[i] - first))
for i in brr:
	print(gcd(gc, first + i), end=' ')


import sys
input = sys.stdin.readline
from itertools import groupby
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
import math

def HalfDead():
	(n, m) = R()
	a = L()
	b = L()
	if n == 1:
		ans = [a[0] + x for x in b]
		print(*ans)
	else:
		a.sort()
		g = 0
		for i in range(1, n):
			g = math.gcd(g, a[i] - a[0])
		ans = [math.gcd(a[0] + b[i], g) for i in range(m)]
		print(*ans)
HalfDead()


import sys, math, heapq, queue
fast_input = sys.stdin.readline
(n, m) = map(int, fast_input().split())
a = list(map(int, fast_input().split()))
b = list(map(int, fast_input().split()))
if n == 1:
	for i in range(m):
		print(a[0] + b[i], end=' ')
else:
	g = a[1] - a[0]
	for i in range(1, n):
		g = math.gcd(g, a[i] - a[0])
	for i in range(m):
		print(math.gcd(a[0] + b[i], g), end=' ')


from collections import Counter
import string
import bisect
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
testcases = 1
for _ in range(testcases):
	(n, m) = vary(2)
	num = array_int()
	b = array_int()
	if n == 1:
		for i in range(m):
			print(num[0] + b[i], end=' ')
		continue
	gt = abs(num[0] - num[1])
	for i in range(1, n - 1):
		gt = math.gcd(abs(num[i] - num[i + 1]), gt)
	for i in range(m):
		print(math.gcd(b[i] + num[-1], gt), end=' ')


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
l = []
if n == 1:
	result = arr[0]
	for j in range(m):
		l.append(result + arr2[j])
	print(*l)
else:
	result = abs(arr[1] - arr[0])
	for i in range(2, n):
		result = gcd(result, abs(arr[i] - arr[0]))
	for j in range(m):
		l.append(gcd(arr[0] + arr2[j], result))
	print(*l)


import math
(n, k) = map(int, input().split())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
if n == 1:
	for j in a2:
		print(j + a1[0], end=' ')
else:
	ew = a1[0]
	g = 0
	it = 0
	for u in range(1, n):
		a1[u] = abs(ew - a1[u])
		if a1[u] != 0 and g == 0:
			g = a1[u]
	for p in range(1, n):
		if a1[p] != 0:
			g = math.gcd(g, a1[p])
	for u in a2:
		print(math.gcd(u + ew, g), end=' ')


def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x
(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = []
if n > 1:
	baseGCD = a[1] - a[0]
	for i in range(2, n):
		baseGCD = gcd(baseGCD, a[i] - a[0])
	for i in range(m):
		ans.append(gcd(baseGCD, a[0] + b[i]))
else:
	for i in range(m):
		ans.append(a[0] + b[i])
oneLineArrayPrint(ans)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor
from itertools import combinations, permutations
from bisect import *
from fractions import Fraction
from heapq import *
from random import randint

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	t = 0
	for i in range(1, n):
		t = gcd(t, abs(a[i] - a[i - 1]))
	for i in range(m):
		b[i] = gcd(t, b[i] + a[0])
	print(*b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
(n, m) = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
ans = -1
for i in range(1, len(list1)):
	if ans == -1:
		ans = list1[i] - list1[0]
	ans = math.gcd(list1[i] - list1[0], ans)
for i in range(m):
	if ans == -1:
		print(list2[i] + list1[0], end=' ')
	else:
		print(math.gcd(ans, list2[i] + list1[0]), end=' ')
print()


from math import gcd
(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
curGcd = None
for i in range(1, n):
	if curGcd is None:
		curGcd = a[i] - a[0]
	else:
		curGcd = gcd(curGcd, a[i] - a[0])
result = []
for val in b:
	if curGcd is not None:
		result.append(gcd(curGcd, a[0] + val))
	else:
		result.append(val + a[0])
print(*result)


import math
(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a.sort()
if len(a) == 1:
	for i in range(m):
		print(a[0] + b[i], end=' ')
else:
	gcd1 = a[1] - a[0]
	for i in range(2, len(a)):
		gcd1 = math.gcd(gcd1, a[i] - a[i - 1])
	for i in range(m):
		print(math.gcd(gcd1, a[0] + b[i]), end=' ')


from math import *
(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
ans = []
mn = min(l1)
gd = 0
for i in range(n):
	gd = gcd(gd, abs(l1[i] - mn))
for i in range(m):
	ans.append(gcd(gd, l2[i] + mn))
print(*ans)


from math import *
(n, m) = [int(i) for i in input().split()]
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
g = 0
for i in range(1, n):
	g = gcd(g, a1[i] - a1[0])
for i in range(m):
	print(gcd(g, a2[i] + a1[0]), end=' ')
print()


import sys
import math, bisect, operator
(inf, m) = (float('inf'), 10 ** 9 + 7)
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
I = lambda : int(sys.stdin.readline())
neo = lambda : map(int, sys.stdin.readline().split())
Neo = lambda : list(map(int, sys.stdin.readline().split()))
(n, m) = neo()
A = Neo()
B = Neo()
A.sort()
C = []
A = A[::-1]
if n == 1:
	for i in B:
		print(A[0] + i, end=' ')
	exit()
for (i, j) in zip(A, A[1:]):
	C += [i - j]
gcd = C[0]
for i in C[1:]:
	gcd = math.gcd(gcd, i)
for i in B:
	t = math.gcd(gcd, i + A[-1])
	print(t, end=' ')


from math import gcd
(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
nod = 0
for i in range(n):
	nod = gcd(nod, abs(a[0] - a[i]))
for j in range(m):
	print(gcd(nod, a[0] + b[j]), end=' ')


import math
(n, m) = map(int, input().strip().split(' '))
a = [int(_) for _ in input().strip().split(' ')]
g = 0
for i in range(1, n):
	g = math.gcd(g, abs(a[i] - a[0]))
b = [int(_) for _ in input().strip().split(' ')]
for i in range(m):
	print(math.gcd(b[i] + a[0], g), end=' ')


def gcd(a, b):
	while b:
		a %= b
		if not a:
			return b
		b %= a
	return a

def abs(a):
	if a >= 0:
		return a
	else:
		return -a
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * m
g = 0
for i in range(1, n):
	g = gcd(abs(a[i] - a[0]), g)
for i in range(m):
	c[i] = gcd(a[0] + b[i], g)
for i in c:
	print(i, sep=' ', end=' ')


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = 0
for i in range(1, n):
	d = gcd(d, abs(a[i] - a[i - 1]))
ans = [gcd(d, a[0] + elm) for elm in b]
print(*ans)


from collections import deque, defaultdict
from math import gcd

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans = gcd(ans, abs(a[i + 1] - a[i]))
	for i in range(m):
		pr = gcd(a[0] + b[i], ans)
		print(pr, end=' ')

def main():
	t = 1
	for _ in range(t):
		solve()
main()


import math
import sys
import functools

def inp():
	return sys.stdin.readline().strip()

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
(n, m) = map_inp(int)
a1 = list_inp(int)
b1 = list_inp(int)
for i in range(1, n):
	a1[i] = a1[i] - a1[0]
if n > 1:
	gcd = functools.reduce(math.gcd, a1[1:])
	ans_arr = []
	for item in b1:
		ans_arr.append(math.gcd(a1[0] + item, gcd))
	print(*ans_arr)
else:
	for item in b1:
		print(a1[0] + item, end=' ')


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n > 2:
	g = math.gcd(a[2] - a[0], a[1] - a[0])
	for i in range(3, n):
		g = math.gcd(g, a[i] - a[0])
	ans = []
	for i in range(m):
		s = math.gcd(g, a[0] + b[i])
		ans.append(s)
	print(*ans)
elif n == 1:
	g = a[0] + b[0]
	ans = []
	for i in range(m):
		s = a[0] + b[i]
		ans.append(s)
	print(*ans)
else:
	g = a[-1] - a[0]
	ans = []
	for i in range(m):
		s = math.gcd(g, a[0] + b[i])
		ans.append(s)
	print(*ans)


from functools import reduce
from math import gcd
input()
a = list(map(int, input().split()))
if len(a) == 1:
	for v in map(int, input().split()):
		print(v + a[0], end=' ')
else:
	g = reduce(gcd, [v - a[0] for v in a[1:]])
	for v in map(int, input().split()):
		print(gcd(g, v + a[0]), end=' ')


import math
(n, m) = (int(x) for x in input().split())
l1 = list(set([int(x) for x in input().split()]))
l2 = [int(x) for x in input().split()]
if len(l1) == 1:
	print(*[x + l1[0] for x in l2])
	exit(0)
gcd = l1[1] - l1[0]
for i in range(1, len(l1)):
	gcd = math.gcd(gcd, l1[i] - l1[i - 1])
print(*[math.gcd(l1[0] + x, gcd) for x in l2])


import math
(t, a, g) = (input(), list(map(int, input().split())), 0)
for v in a[1:]:
	g = math.gcd(g, v - a[0])
print(*[math.gcd(g, v + a[0]) for v in map(int, input().split())])