There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {x_1, x_2, x_3, x_4} (x_1 ≤ x_2 ≤ x_3 ≤ x_4) arithmetic mean is $\frac{x_{1} + x_{2} + x_{3} + x_{4}}{4}$, median is $\frac{x_{2} + x_{3}}{2}$ and range is x_4 - x_1. The arithmetic mean and median are not necessary integer. It is well-known that if those three numbers are same, boxes will create a "debugging field" and codes in the field will have no bugs.

For example, 1, 1, 3, 3 is the example of 4 numbers meeting the condition because their mean, median and range are all equal to 2.

Jeff has 4 special boxes of candies. However, something bad has happened! Some of the boxes could have been lost and now there are only n (0 ≤ n ≤ 4) boxes remaining. The i-th remaining box contains a_{i} candies.

Now Jeff wants to know: is there a possible way to find the number of candies of the 4 - n missing boxes, meeting the condition above (the mean, median and range are equal)?


-----Input-----

The first line of input contains an only integer n (0 ≤ n ≤ 4).

The next n lines contain integers a_{i}, denoting the number of candies in the i-th box (1 ≤ a_{i} ≤ 500).


-----Output-----

In the first output line, print "YES" if a solution exists, or print "NO" if there is no solution.

If a solution exists, you should output 4 - n more lines, each line containing an integer b, denoting the number of candies in a missing box.

All your numbers b must satisfy inequality 1 ≤ b ≤ 10^6. It is guaranteed that if there exists a positive integer solution, you can always find such b's meeting the condition. If there are multiple answers, you are allowed to print any of them.

Given numbers a_{i} may follow in any order in the input, not necessary in non-decreasing.

a_{i} may have stood at any positions in the original set, not necessary on lowest n first positions.


-----Examples-----
Input
2
1
1

Output
YES
3
3

Input
3
1
1
1

Output
NO

Input
4
1
2
2
3

Output
YES



-----Note-----

For the first sample, the numbers of candies in 4 boxes can be 1, 1, 3, 3. The arithmetic mean, the median and the range of them are all 2.

For the second sample, it's impossible to find the missing number of candies.

In the third example no box has been lost and numbers satisfy the condition.

You may output b in any order.

Difficulty: HARD
Tags: Complete search

Mathematics

Constructive algorithms
Skill types: Complete search

Starter code:

Solutions:
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = sorted(a)
if n == 0:
	b = [1, 1, 3, 3]
elif n == 1:
	b = [a[0], a[0] * 3, a[0] * 3]
elif n == 2:
	if a[0] == a[1]:
		b = [a[1] * 3, a[1] * 3]
	elif a[0] * 3 >= a[1]:
		b = [a[0] * 3, a[0] * 4 - a[1]]
	else:
		b = None
elif n == 4:
	if a[0] * 3 == a[3] and a[0] * 4 == a[1] + a[2]:
		b = []
	else:
		b = None
elif a[0] * 3 >= a[2] and a[0] * 4 == a[1] + a[2]:
	b = [a[0] * 3]
elif a[0] * 3 == a[2]:
	b = [a[0] * 4 - a[1]]
elif a[2] * 4 / 3 == a[0] + a[1]:
	b = [a[2] // 3]
else:
	b = None
if b == None:
	print('NO')
else:
	print('YES')
	for x in b:
		print(x)


n = int(input())
x = []
for i in range(n):
	x.append(int(input()))
x = sorted(x)
a = []
good = False
if len(x) == 0:
	a = [1, 1, 3, 3]
	good = True
elif len(x) == 1:
	a = [x[0], 3 * x[0], 3 * x[0]]
	good = True
elif len(x) == 2:
	if 4 * x[0] - x[1] > 0:
		a = [4 * x[0] - x[1], 3 * x[0]]
		good = True
elif len(x) == 3:
	if x[2] == 4 * x[0] - x[1]:
		good = True
		a = [3 * x[0]]
	elif x[2] == 3 * x[0]:
		good = True
		a = [4 * x[0] - x[1]]
	elif x[2] % 3 == 0 and x[1] == 4 * (x[2] // 3) - x[0]:
		good = True
		a = [x[2] // 3]
elif len(x) == 4:
	if x[2] == 4 * x[0] - x[1] and 3 * x[0] == x[3]:
		good = True
if good:
	print('YES')
	for i in a:
		print(i)
else:
	print('NO')


n = int(input())
aa = []
ans = 'NO'
ss = []
for i in range(0, n):
	aa.append(int(input()))
for a in range(1, 501):
	for b in range(a, 2 * a + 2):
		possible = [a, b, 4 * a - b, 3 * a]
		for ab in aa:
			if ab in possible:
				possible.remove(ab)
		if len(possible) == 4 - n:
			ans = 'YES'
			ss = possible
			break
	if ans == 'YES':
		break
if ans == 'YES':
	print(ans)
	for i in ss:
		print(i)
else:
	print(ans)


n = int(input())
ar = [int(input()) for x in range(n)]
ar.sort()
foobar = 1

def out(*g):
	g = list(g)
	g.sort()
	print('YES')
	for x in g:
		print(x)

def check(x1, x2, x3, x4):
	l = [x1, x2, x3, x4]
	s = sum(l) / 4
	if s != int(s):
		return False
	l.sort()
	m = (l[1] + l[2]) / 2
	if m != int(m):
		return False
	d = l[3] - l[0]
	if not s == m == d:
		return False
	return True

def _0():
	print('YES')
	print(1)
	print(1)
	print(3)
	print(3)

def _1():
	x = ar[0]
	print('YES')
	print(x)
	print(3 * x)
	print(3 * x)

def _2():
	(x, y) = ar
	if x * 3 < y:
		print('NO')
	else:
		print('YES')
		print(4 * x - y)
		print(3 * x)

def _3():
	x = ar[0]
	y = ar[1]
	z = ar[2]
	if x * 3 < z:
		print('NO')
	else:
		print('YES')
		print(3 * x)

def _3():
	ar.sort()
	m = (max(ar) + 10) * 10
	for x in range(1, m):
		if check(x, *ar):
			out(x)
			return
	print('NO')

def _4():
	r = check(*ar)
	if r == False:
		print('NO')
	else:
		print('YES')
vars()['_' + str(n)]()


import itertools

def check(*xs):
	return sum(xs) == 2 * sum(xs[1:3]) == 4 * (xs[-1] - xs[0]) and all([0 < x <= 10 ** 6 for x in xs]) and (tuple(sorted(xs)) == xs)

def solve(x1=None, x2=None, x3=None, x4=None):
	x = None
	if x1 is not None:
		x = 2 * x1
		if x4 is not None and 3 * x1 != x4:
			return
		x4 = 3 * x1
	if x4 is not None:
		if 2 * x4 % 3 != 0:
			return
		x = 2 * x4 // 3
		if x1 is not None and x // 2 != x1:
			return
		x1 = x // 2
	if x is None:
		if (x2 + x3) % 2 != 0:
			return
		x = (x2 + x3) // 2
		if x % 2 != 0:
			return
		x1 = x // 2
		x4 = 3 * x1
	elif x2 is not None and x3 is None:
		x3 = 2 * x - x2
	elif x3 is not None and x2 is None:
		x2 = 2 * x - x3
	if check(x1, x2, x3, x4):
		return (x1, x2, x3, x4)
n = int(input())
if n == 0:
	print('YES')
	print(str.join('\n', list(map(str, (1, 1, 3, 3)))))
elif n == 1:
	a = int(input())
	print('YES')
	print(str.join('\n', [str(x * a) for x in (1, 3, 3)]))
elif n == 4:
	a = []
	for _ in range(n):
		a.append(int(input()))
	print('YES' if check(*sorted(a)) else 'NO')
else:
	a = [None] * 4
	for i in range(n):
		a[i] = int(input())
	for comb in itertools.permutations(a, 4):
		nums = list(filter(bool, comb))
		if nums != sorted(nums):
			continue
		r = solve(*comb)
		if r is not None:
			print('YES')
			for (x, xc) in zip(r, comb):
				if xc is None:
					print(x)
			return
	else:
		print('NO')


n = int(input())
t = sorted([int(input()) for i in range(n)])
s = None
if n == 0:
	s = [1, 1, 3, 3]
elif n == 1:
	a = t[0]
	s = [a, 3 * a, 3 * a]
elif n == 2:
	(a, b) = t
	if a * 3 >= b:
		s = [3 * a, 4 * a - b]
elif n == 3:
	(a, b, c) = t
	if 4 * a == b + c:
		s = [3 * a]
	elif 4 * c / 3 == a + b:
		s = [c // 3]
	elif c == 3 * a:
		s = [4 * a - b]
elif n == 4:
	(a, b, c, d) = t
	if d + a == 4 * a == b + c:
		s = []
if s != None:
	print('YES')
	for a in s:
		print(a)
else:
	print('NO')


n = int(input())
numbers = []
for k in range(0, n):
	numbers.append(int(input()))
numbers.sort()

def median(a):
	return (a[1] + a[2]) * 2

def mean(a):
	return sum(a)

def ran(a):
	return (a[-1] - a[0]) * 4

def test_solution(numbers):
	for k in numbers:
		if k < 1 or k > 10 ** 6:
			return False
	med = median(numbers)
	men = mean(numbers)
	ra = ran(numbers)
	return med == men and men == ra and (med == ra)

def calculate_rest(numbers):
	(a, b) = numbers
	s = a - b
test_solution([2, 4, 4, 6])
if n == 4:
	if test_solution(numbers):
		print('YES')
	else:
		print('NO')
elif n == 0:
	print('YES')
	print(1)
	print(1)
	print(3)
	print(3)
elif n == 1:
	print('YES')
	print(2 * numbers[0])
	print(2 * numbers[0])
	print(3 * numbers[0])
elif n == 3:
	(x, y, z) = numbers
	found = False
	if z == 3 * x:
		t = 4 * x - y
		if test_solution(sorted([x, y, t, z])):
			found = True
			print('YES')
			print(t)
	elif test_solution(sorted([x, y, z, 3 * x])):
		print('YES')
		print(3 * x)
		found = True
	elif test_solution(sorted([x, y, z, z // 3])):
		print('YES')
		print(z // 3)
		found = True
	if not found:
		print('NO')
else:
	found = False
	fillers = []
	(b, c) = numbers
	for a in range(1, b + 1):
		d = 3 * a
		if test_solution(sorted([a, b, c, d])):
			found = True
			fillers = [a, d]
	(a, b) = numbers
	d = 3 * a
	c = a + d - b
	if test_solution(sorted([a, b, c, d])):
		found = True
		fillers = [c, d]
	(c, d) = numbers
	a = d // 3
	b = a + d - c
	if test_solution(sorted([a, b, c, d])):
		found = True
		fillers = [a, b]
	fillers.sort()
	if found:
		print('YES')
		for k in fillers:
			print(k)
	else:
		print('NO')


def check(a, b, c, d):
	arr = [a, b, c, d]
	arr.sort()
	(x, y, z, w) = (arr[0], arr[1], arr[2], arr[3])
	return w == 3 * x and x + w == y + z
a = int(input())
if a == 0:
	print('YES')
	print('1\n1\n3\n3')
if a == 1:
	x = int(input())
	print('YES')
	print(x)
	print(3 * x)
	print(3 * x)
if a == 2:
	x = int(input())
	y = int(input())
	(x, y) = (min(x, y), max(x, y))
	if y > 3 * x:
		print('NO')
	else:
		print('YES')
		print(4 * x - y)
		print(3 * x)
if a == 3:
	nums = [int(input()) for i in range(3)]
	nums.sort()
	(x, y, z) = (nums[0], nums[1], nums[2])
	for i in range(1, 10 ** 5):
		if check(x, y, z, i):
			print('YES')
			print(i)
			exit()
	print('NO')
if a == 4:
	nums = [int(input()) for i in range(4)]
	nums.sort()
	if nums[-1] == 3 * nums[0] and nums[0] + nums[3] == nums[1] + nums[2]:
		print('YES')
	else:
		print('NO')


def check(arr):
	arr.sort()
	a = sum(arr) / len(arr)
	b = (arr[1] + arr[2]) / 2
	c = arr[-1] - arr[0]
	return a == b == c
n = int(input())
arr = [int(input()) for i in range(n)]
arr.sort()
if n == 0:
	print('YES')
	print(1)
	print(1)
	print(3)
	print(3)
elif n == 4:
	if check(arr):
		print('YES')
	else:
		print('NO')
elif n == 2:
	if 3 * arr[0] < arr[1]:
		print('NO')
	else:
		print('YES')
		print(4 * arr[0] - arr[1])
		print(3 * arr[0])
elif n == 3:
	if 3 * arr[0] < arr[2]:
		print('NO')
	elif check([arr[0], arr[1], arr[2], 3 * arr[0]]):
		print('YES')
		print(3 * arr[0])
	elif check([arr[2] / 3, arr[0], arr[1], arr[2]]):
		print('YES')
		print(arr[2] // 3)
	elif check([arr[0], arr[1], arr[0] + arr[2] - arr[1], arr[2]]):
		print('YES')
		print(arr[0] + arr[2] - arr[1])
	else:
		print('NO')
elif n == 1:
	print('YES')
	print(arr[0])
	print(arr[0] * 3)
	print(arr[0] * 3)


n = int(input())
t = [int(input()) for q in range(n)]
for i in range(1, 501):
	for j in range(i, 2 * i + 1):
		s = [i, j, 4 * i - j, 3 * i]
		for k in t:
			if k not in s:
				break
			s.remove(k)
		else:
			print('YES')
			for q in s:
				print(q)
			exit()
print('NO')


n = int(input())
boxes = []
for i in range(n):
	boxes.append(int(input()))
if n == 0:
	print('YES')
	print(1, '\n', 1, '\n', 3, '\n', 3, sep='')
if n == 1:
	print('YES')
	print(boxes[0], '\n', 3 * boxes[0], '\n', 3 * boxes[0], sep='')
if n == 2:
	boxes = sorted(boxes)
	if 3 * boxes[0] < boxes[1]:
		print('NO')
	else:
		print('YES')
		print(int(4 * boxes[0] - boxes[1]), '\n', int(3 * boxes[0]), sep='')
if n == 3:
	boxes = sorted(boxes)
	if 3 * boxes[0] < boxes[2]:
		print('NO')
	elif (boxes[0] + boxes[1] + boxes[2] + 3 * boxes[0]) / 4 == (boxes[1] + boxes[2]) / 2 and (boxes[1] + boxes[2]) / 2 == 2 * boxes[0]:
		print('YES')
		print(int(3 * boxes[0]), sep='')
	elif (boxes[2] / 3 + boxes[0] + boxes[1] + boxes[2]) / 4 == (boxes[1] + boxes[0]) / 2 and (boxes[1] + boxes[0]) / 2 == 2 * boxes[2] / 3:
		print('YES')
		print(int(boxes[2] / 3))
	elif (2 * boxes[0] + 2 * boxes[2]) / 4 == boxes[2] - boxes[0]:
		print('YES')
		print(int(boxes[0] - boxes[1] + boxes[2]), sep='')
	else:
		print('NO')
if n == 4:
	boxes = sorted(boxes)
	mean = (boxes[0] + boxes[1] + boxes[2] + boxes[3]) / 4
	median = (boxes[1] + boxes[2]) / 2
	ran = boxes[3] - boxes[0]
	if mean == median and mean == ran:
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
res = None
if n == 0:
	res = [1, 1, 3, 3]
elif n == 1:
	res = [a[0], 3 * a[0], 3 * a[0]]
elif n == 2 and a[1] <= 3 * a[0]:
	res = [a[0] * 4 - a[1], a[0] * 3]
elif n == 3:
	for v in range(1501):
		s = a + [v]
		s.sort()
		if s[0] * 3 == s[3] and s[1] + s[2] == 4 * s[0]:
			res = [v]
			break
elif n == 4 and a[0] * 3 == a[3] and (a[1] + a[2] == 4 * a[0]):
	res = []
if res == None:
	print('NO')
else:
	print('YES')
	for b in res:
		print(b)


boxes = int(input())
candy_supply = []
for i in range(boxes):
	candies = int(input())
	candy_supply.append(candies)
candy_supply = sorted(candy_supply)
if boxes == 4:
	c_range = candy_supply[3] - candy_supply[0]
	a_mean = (candy_supply[0] + candy_supply[1] + candy_supply[2] + candy_supply[3]) / 4
	median = (candy_supply[2] + candy_supply[1]) / 2
	if c_range == a_mean == median:
		print('YES')
	else:
		print('NO')
elif boxes == 0:
	print('YES')
	candy_supply = [1, 2, 2, 3]
	for box in candy_supply:
		print(box)
elif boxes == 1:
	print('YES')
	x1 = candy_supply[0]
	candy_supply.append(2 * x1)
	candy_supply.append(2 * x1)
	candy_supply.append(3 * x1)
	print(candy_supply[1])
	print(candy_supply[2])
	print(candy_supply[3])
elif boxes == 3:
	median = (candy_supply[1] + candy_supply[2]) / 2
	if 2 * candy_supply[0] == median:
		print('YES')
		candy_supply.append(int(median * 3 / 2))
		print(candy_supply[3])
	elif candy_supply[2] == candy_supply[0] * 3:
		print('YES')
		x1 = candy_supply[0]
		x4 = candy_supply[2]
		x2 = candy_supply[1]
		x3 = 4 * x1 - x2
		print(int(x3))
		if x3 > x2:
			temp = x2
			x2 = x3
			x3 = temp
		candy_supply = [x1, x2, x3, x4]
	elif 4 * candy_supply[2] == 3 * (candy_supply[0] + candy_supply[1]) and candy_supply[2] % 3 == 0:
		print('YES')
		x4 = candy_supply[2]
		x2 = candy_supply[0]
		x3 = candy_supply[1]
		x1 = x4 / 3
		candy_supply = [x1, x2, x3, x4]
		print(int(x1))
	else:
		print('NO')
elif boxes == 2:
	x1 = candy_supply[0]
	x2 = candy_supply[1]
	if 2 * x1 >= x2:
		print('YES')
		x3 = 4 * x1 - x2
		x4 = 3 * x1
		candy_supply.append(x3)
		candy_supply.append(x4)
		print(int(x3))
		print(int(x4))
	elif 3 * candy_supply[0] >= candy_supply[1] >= 2 * candy_supply[0]:
		x1 = candy_supply[0]
		x3 = candy_supply[1]
		x2 = 4 * x1 - x3
		x4 = 3 * x1
		candy_supply = [x1, x2, x3, x4]
		print('YES')
		print(int(x2))
		print(int(x4))
	elif 3 * candy_supply[0] == candy_supply[1]:
		pass
	elif candy_supply[0] > 0 and (candy_supply[0] + candy_supply[1]) % 4 == 0 and ((candy_supply[0] + candy_supply[1]) / 2 >= candy_supply[1] - candy_supply[0]):
		x2 = candy_supply[0]
		x3 = candy_supply[1]
		x1 = (candy_supply[0] + candy_supply[1]) / 4
		x4 = 3 * x1
		candy_supply = [x1, x2, x3, x4]
		print('YES')
		print(int(x1))
		print(int(x4))
	elif candy_supply[0] * 3 / 2 <= candy_supply[1] <= 3 * candy_supply[0] and candy_supply[1] % 3 == 0:
		x2 = candy_supply[0]
		x4 = candy_supply[1]
		x1 = x4 / 3
		x3 = 4 / 3 * x4 - x2
		candy_supply = [x1, x2, x3, x4]
		print('YES')
		print(int(x1))
		print(int(x3))
	elif (candy_supply[0] + 1) * 3 / 4 <= candy_supply[1] <= candy_supply[0] * 3 / 2 and candy_supply[1] % 3 == 0:
		x2 = candy_supply[0]
		x4 = candy_supply[1]
		x1 = x4 / 3
		x3 = 4 / 3 * x4 - x2
		candy_supply = [x1, x2, x3, x4]
		print('YES')
		print(int(x1))
		print(int(x3))
	else:
		print('NO')


__author__ = 'zhan'
candy = [0]
n = int(input())
for i in range(n):
	candy.append(int(input()))
if n == 0:
	print('YES\n1\n1\n3\n3')
elif n == 4:
	candy.sort()
	if candy[4] == 3 * candy[1] and candy[2] + candy[3] == 4 * candy[1]:
		print('YES')
	else:
		print('NO')
elif n == 1:
	ans = [str(2 * candy[1]), str(2 * candy[1]), str(3 * candy[1])]
	ans.insert(0, 'YES')
	print('\n'.join(ans))
elif n == 3:
	candy.sort()
	if candy[3] % 3 == 0 and 3 * (candy[1] + candy[2]) == 4 * candy[3]:
		print('YES')
		print(candy[3] // 3)
	elif 3 * candy[1] == candy[3]:
		print('YES')
		print(4 * candy[1] - candy[2])
	elif 4 * candy[1] == candy[2] + candy[3]:
		print('YES')
		print(3 * candy[1])
	else:
		print('NO')
else:
	candy.sort()
	if candy[2] == 3 * candy[1]:
		ans = ['YES', str(2 * candy[1]), str(2 * candy[1])]
		print('\n'.join(ans))
	elif candy[2] < 3 * candy[1]:
		ans = ['YES', str(4 * candy[1] - candy[2]), str(3 * candy[1])]
		print('\n'.join(ans))
	else:
		print('NO')


n = int(input())
if n == 4:
	(x1, x2, x3, x4) = (int(input()), int(input()), int(input()), int(input()))
	(x1, x2, x3, x4) = sorted([x1, x2, x3, x4])
	if x4 == 3 * x1 and 4 * x1 == x2 + x3:
		print('YES')
	else:
		print('NO')
elif n == 0:
	print('YES\n1\n1\n3\n3')
elif n == 1:
	a = int(input())
	print('YES')
	print(2 * a)
	print(2 * a)
	print(3 * a)
elif n == 2:
	(a, b) = (int(input()), int(input()))
	(a, b) = sorted([a, b])
	if b == 3 * a:
		print('YES')
		print(2 * a)
		print(2 * a)
	elif 3 * a >= b:
		print('YES')
		print(3 * a)
		print(4 * a - b)
	elif (a + b) % 4 == 0:
		x1 = (a + b) // 4
		x4 = 3 * x1
		if x1 <= a <= x4 and x1 <= b <= x4:
			print('YES')
			print(x1)
			print(x4)
		elif b % 3 == 0:
			x1 = b // 3
			x3 = b - a
			(a, x3) = (min(a, x3), max(a, x3))
			if x1 <= a <= x3 <= b:
				print('YES')
				print(x1)
				print(x3)
			else:
				print('NO')
		else:
			print('NO')
	elif b % 3 == 0:
		x1 = b // 3
		x3 = b - a
		(a, x3) = (min(a, x3), max(a, x3))
		if x1 <= a <= x3 <= b:
			print('YES')
			print(x1)
			print(x3)
		else:
			print('NO')
	else:
		print('NO')
else:
	(a, b, c) = (int(input()), int(input()), int(input()))
	(a, b, c) = sorted([a, b, c])
	if c % 3 == 0:
		x1 = c // 3
	else:
		x1 = 10 ** 9
	x2 = 4 * a - b
	x3 = 4 * a - b
	x4 = 3 * a
	if x1 <= a <= b <= c and 4 * x1 == a + b and (c == 3 * x1):
		print('YES')
		print(x1)
	elif a <= x2 <= b <= c and c == 3 * a and (4 * a == x2 + b):
		print('YES')
		print(x2)
	elif a <= b <= x3 <= c and c == 3 * a and (4 * a == b + x3):
		print('YES')
		print(x3)
	elif c <= x4 and 4 * a == b + c and (3 * a == x4):
		print('YES')
		print(x4)
	else:
		print('NO')


def check(a, b, c, d):
	bad = [a, b, c, d]
	bad.sort()
	(x, y, z, w) = (bad[0], bad[1], bad[2], bad[3])
	if w == 3 * x and x + w == y + z:
		return True
	return False
a = int(input())
if a == 0:
	print('YES')
	print('1')
	print('1')
	print('3')
	print('3')
if a == 1:
	x = int(input())
	print('YES')
	print(x)
	print(3 * x)
	print(3 * x)
if a == 2:
	x = int(input())
	y = int(input())
	(x, y) = (min(x, y), max(x, y))
	if y > 3 * x:
		print('NO')
	else:
		print('YES')
		print(4 * x - y)
		print(3 * x)
if a == 3:
	nums = [int(input()) for i in range(3)]
	nums.sort()
	(x, y, z) = (nums[0], nums[1], nums[2])
	for i in range(1, 10 ** 5):
		if check(x, y, z, i):
			print('YES')
			print(i)
			quit()
	print('NO')
if a == 4:
	nums = [int(input()) for i in range(4)]
	nums.sort()
	if nums[-1] == 3 * nums[0] and nums[0] + nums[3] == nums[1] + nums[2]:
		print('YES')
	else:
		print('NO')


import sys

def calc(boxes):
	s = sorted(boxes)
	am = sum(s) / 4
	m = (s[1] + s[2]) / 2
	r = float(s[3] - s[0])
	return (am, m, r)
n = int(input())
boxes = []
for i in range(n):
	boxes.append(int(input()))
if n == 0:
	print('YES')
	print('1')
	print('1')
	print('3')
	print('3')
elif n == 1:
	print('YES')
	print(boxes[0] * 2)
	print(boxes[0] * 2)
	print(boxes[0] * 3)
elif n == 2:
	if boxes[0] == boxes[1]:
		print('YES')
		print(boxes[0] * 3)
		print(boxes[0] * 3)
		sys.exit(0)
	a = min(boxes[0], boxes[1])
	b = max(boxes[0], boxes[1])
	if b > a * 3:
		print('NO')
		sys.exit(0)
	print('YES')
	if b == a * 3:
		print(a * 2)
		print(a * 2)
	elif b < a * 2:
		dist = a * 2 - b
		print(a * 2 + dist)
		print(a * 3)
	else:
		dist = b - a * 2
		print(a * 2 - dist)
		print(a * 3)
elif n == 3:
	boxes.append(0)
	for i in range(1, 2000):
		boxes[3] = i
		(a, m, r) = calc(boxes)
		if a == m == r:
			print('YES')
			print(i)
			break
	else:
		print('NO')
else:
	(a, m, r) = calc(boxes)
	if a == m == r:
		print('YES')
	else:
		print('NO')


n = int(input())
b = sorted([int(input()) for i in range(n)])

def check(gen, b):
	diff = []
	pos1 = 0
	pos2 = 0
	c = 0
	while pos1 != len(gen) and pos2 != len(b):
		if gen[pos1] == b[pos2]:
			c += 1
			pos2 += 1
		else:
			diff.append(gen[pos1])
		pos1 += 1
	diff += gen[pos1:]
	return None if c != len(b) else diff
for i in range(1, 500 + 1):
	for j in range(i, 3 * i + 1):
		r = check([i, j, 4 * i - j, 3 * i], b)
		if r is not None:
			print('YES')
			for x in r:
				print(x)
			break
	else:
		continue
	break
else:
	print('NO')


import time

def func(a, b, c, d):
	if a <= b and b <= c and (c <= d) and (c == 4 * a - b) and (d == 3 * a):
		return True
	return False
n = int(input())
A = []
for i in range(n):
	A.append(int(input()))
A = sorted(A)
start = time.time()
ans = False
if n == 4:
	if func(A[0], A[1], A[2], A[3]) == False:
		print('NO')
	else:
		print('YES')
elif n == 3:
	if func(A[0], A[1], A[2], 3 * A[0]) == False:
		if func(A[0], A[1], 4 * A[0] - A[1], A[2]) == False and func(A[0], 4 * A[0] - A[1], A[1], A[2]) == False:
			if func(A[2], 3 * A[0], 3 * A[1], 3 * A[2]) == False or divmod(A[2], 3)[1] != 0:
				print('NO')
			else:
				print('YES')
				print(divmod(A[2], 3)[0])
		else:
			print('YES')
			print(4 * A[0] - A[1])
	else:
		print('YES')
		print(3 * A[0])
elif n == 2:
	if 4 * A[0] - A[1] > 0:
		print('YES')
		print(4 * A[0] - A[1])
		print(3 * A[0])
	else:
		print('NO')
elif n == 1:
	print('YES')
	print(A[0] + 1)
	print(3 * A[0] - 1)
	print(3 * A[0])
elif n == 0:
	print('YES')
	print(1)
	print(2)
	print(2)
	print(3)
finish = time.time()


n = int(input())
if n == 0:
	print('YES')
	print(1)
	print(1)
	print(3)
	print(3)
else:
	lis = []
	for i in range(n):
		lis.append(int(input()))
	lis.sort()
	if n == 1:
		print('YES')
		print(lis[0])
		print(3 * lis[0])
		print(3 * lis[0])
	if n == 2:
		if lis[1] - lis[0] > 2 * lis[0]:
			print('NO')
		else:
			print('YES')
			print(4 * lis[0] - lis[1])
			print(3 * lis[0])
	if n == 3:
		if lis[1] + lis[2] == 4 * lis[0] and max(lis[1], lis[2]) <= 3 * lis[0]:
			print('YES')
			print(3 * lis[0])
		elif lis[2] == 3 * lis[0]:
			print('YES')
			print(4 * lis[0] - lis[1])
		elif (lis[0] + lis[1]) * 3 == 4 * lis[2]:
			print('YES')
			print(int(lis[2] / 3))
		else:
			print('NO')
	if n == 4:
		if lis[3] == 3 * lis[0] and lis[1] + lis[2] == 4 * lis[0]:
			print('YES')
		else:
			print('NO')


__author__ = 'zhan'
n = int(input())
candy = sorted([int(input()) for _ in range(n)])
ans = None
if n == 0:
	ans = [1, 1, 3, 3]
elif n == 4:
	(a, b, c, d) = candy
	if d == 3 * a and b + c == 4 * a:
		ans = []
elif n == 1:
	a = candy[0]
	ans = [2 * a, 2 * a, 3 * a]
elif n == 3:
	(a, b, c) = candy
	if c % 3 == 0 and 3 * (a + b) == 4 * c:
		ans = [c // 3]
	elif 3 * a == c:
		ans = [4 * a - b]
	elif 4 * a == b + c:
		ans = [3 * a]
else:
	(a, b) = candy
	if b == 3 * a:
		ans = [2 * a, 2 * a]
	elif b < 3 * a:
		ans = [4 * a - b, 3 * a]
if ans is not None:
	print('YES')
	for x in ans:
		print(x)
else:
	print('NO')


n = int(input())
a = sorted([int(input()) for _ in range(n)])
b = None
if n == 0:
	b = [1, 1, 3, 3]
elif n == 1:
	x = a[0]
	b = [x, x * 3, x * 3]
elif n == 2:
	(x, y) = a
	if x == y:
		b = [x * 3, x * 3]
	elif x * 3 >= y:
		b = [x * 3, x * 4 - y]
elif n == 3:
	(x, y, z) = a
	if x * 3 >= z and x * 4 == y + z:
		b = [x * 3]
	elif z + z / 3 == x + y:
		b = [z // 3]
	elif z == x * 3:
		b = [x * 4 - y]
elif n == 4:
	(x, y, z, v) = a
	if v == x * 3 and x * 4 == y + z:
		b = []
if b != None:
	print('YES')
	for x in b:
		print(x)
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))

def ideal(a):
	a.sort()
	mean = sum(a) / 4
	median = (a[1] + a[2]) / 2
	r = max(a) - min(a)
	if mean == median == r:
		print('YES')
	else:
		print('NO')
if len(a) == 4:
	ideal(a)
elif len(a) == 0:
	print('YES')
	print(1)
	print(1)
	print(3)
	print(3)
elif len(a) == 1:
	print('YES')
	print(2 * a[0])
	print(2 * a[0])
	print(3 * a[0])
elif len(a) == 2:
	if 4 * min(a) - max(a) > 0:
		print('YES')
		print(4 * min(a) - max(a))
		print(3 * min(a))
	else:
		print('NO')
elif len(a) == 3:
	if sum(a) - min(a) == 4 * min(a):
		print('YES')
		print(3 * min(a))
	elif max(a) == 3 * min(a):
		print('YES')
		print(8 * min(a) - sum(a))
	elif 3 * sum(a) == 7 * max(a):
		print('YES')
		print(max(a) // 3)
	else:
		print('NO')


def f(a, b, c, d, p):
	if a + b + c + d == b + c << 1 == d - a << 2:
		print('YES')
		for q in p:
			print(q)
		exit()

def g(t, p):
	(i, j, k) = sorted(t + p)
	q = i + j - k
	f(q, i, j, k, p + [q])
	q = i + k - j
	f(i, q, j, k, p + [q])
	f(i, j, q, k, p + [q])
	q = k + j - i
	f(i, j, k, q, p + [q])
n = int(input())
t = [int(input()) for i in range(n)]
if n == 0:
	f(1, 1, 3, 3, [1, 1, 3, 3])
elif n == 1:
	q = t[0]
	f(q, q, 3 * q, 3 * q, [q, 3 * q, 3 * q])
elif n == 4:
	(a, b, c, d) = sorted(t)
	f(a, b, c, d, [])
elif n == 2:
	for i in range(1, 1501):
		g(t, [i])
else:
	g(t, [])
print('NO')


def check(L):
	L.sort()
	return L[1] + L[2] == L[0] * 4 and L[0] * 3 == L[3]
n = int(input())
A = []
for i in range(n):
	A += [int(input())]
A.sort()
if n == 0:
	print('YES', 1, 1, 3, 3, sep='\n')
elif n == 1:
	print('YES', 2 * A[0], 2 * A[0], 3 * A[0], sep='\n')
elif n == 2:
	if A[0] * 3 == A[1]:
		print('YES', 2 * A[0], 2 * A[0], sep='\n')
	elif A[0] * 3 > A[1]:
		print('YES', A[0] * 4 - A[1], A[0] * 3, sep='\n')
	else:
		print('NO')
elif n == 3:
	if A[0] * 4 == A[1] + A[2]:
		print('YES', A[0] * 3, sep='\n')
	elif A[0] * 3 == A[2]:
		print('YES', A[0] * 4 - A[1], sep='\n')
	elif A[2] % 3 == 0 and A[2] // 3 * 4 == A[0] + A[1]:
		print('YES', A[2] // 3, sep='\n')
	else:
		print('NO')
elif n == 4:
	if check(A):
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
if n == 0:
	print('YES', 1, 2, 2, 3, sep='\n')
else:
	for i in range(n):
		a.append(int(input()))
	a.sort()
	if n == 1:
		print('YES', a[0], a[0] * 3, a[0] * 3, sep='\n')
	elif n == 2:
		if a[1] > 3 * a[0]:
			print('NO')
		elif 4 * a[0] - a[1] <= 3 * a[0]:
			if min(a[1], 4 * a[0] - a[1]) == a[1]:
				print('YES', max(a[1], 4 * a[0] - a[1]), 3 * a[0], sep='\n')
			else:
				print('YES', min(a[1], 4 * a[0] - a[1]), 3 * a[0], sep='\n')
		elif a[1] % 3 == 0 and a[0] >= a[1] // 3:
			if a[0] == min(a[0], 4 * a[1] // 3 - a[0]):
				print('YES', a[1] // 3, max(a[0], 4 * a[1] // 3 - a[0]), sep='\n')
			else:
				print('YES', a[1] // 3, min(a[0], 4 * a[1] // 3 - a[0]), sep='\n')
		elif (a[0] + a[1]) % 4 == 0:
			print('YES', (a[0] + a[1]) // 4, 3 * (a[0] + a[1]) // 4, sep='\n')
		else:
			print('NO')
	elif n == 4:
		if a[3] == 3 * a[0] and a[1] + a[2] == 4 * a[0]:
			print('YES')
		else:
			print('NO')
	elif a[2] > 3 * a[0]:
		print('NO')
	elif a[1] + a[2] == a[0] * 4:
		print('YES')
		print(3 * a[0], sep='\n')
	elif a[2] == 3 * a[0]:
		if min(4 * a[0] - a[1], a[1]) == a[1]:
			print('YES', max(4 * a[0] - a[1], a[1]), sep='\n')
		else:
			print('YES', min(4 * a[0] - a[1], a[1]), sep='\n')
	elif a[0] + a[1] == 4 / 3 * a[2] and a[2] % 3 == 0:
		print('YES', a[2] // 3, sep='\n')
	else:
		print('NO')