import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
	N, A, B, C = NMI()
	L = [NI() for _ in range(N)]

	def dfs(bamboo, a, b, c):
		if bamboo == N:
			if a*b*c == 0:
				return 10**100
			a, b, c = sorted([a, b, c], reverse=True)
			res = abs(A-a) + abs(B-b) + abs(C-c)
			return res

		res = 10**100

		res = min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) if a > 0 else min(res, dfs(bamboo + 1, a + L[bamboo], b, c))
		res = min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) if b > 0 else min(res, dfs(bamboo + 1, a, b + L[bamboo], c))
		res = min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) if c > 0 else min(res, dfs(bamboo + 1, a, b, c + L[bamboo]))
		res = min(res, dfs(bamboo + 1, a, b, c))
		return res

	print(dfs(0, 0, 0, 0))



if __name__ == "__main__":
	main() import sys sys import math math from collections import deque sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip NI = lambda: int(input()) NI lambda: int(input()) int(input()) int input() input NMI = lambda: map(int, input().split()) NMI lambda: map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split NLI = lambda: list(NMI()) NLI lambda: list(NMI()) list(NMI()) list NMI() NMI SI = lambda: input() SI lambda: input() input() input [int(num)] * w for _ in range(h) for _ in range(h) _ range(h) range h for _ in range(h) [int(num)] * w [int(num)] int(num) int num w def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] make_grid h h w w num num def main():
	N, A, B, C = NMI()
	L = [NI() for _ in range(N)]

	def dfs(bamboo, a, b, c):
		if bamboo == N:
			if a*b*c == 0:
				return 10**100
			a, b, c = sorted([a, b, c], reverse=True)
			res = abs(A-a) + abs(B-b) + abs(C-c)
			return res

		res = 10**100

		res = min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) if a > 0 else min(res, dfs(bamboo + 1, a + L[bamboo], b, c))
		res = min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) if b > 0 else min(res, dfs(bamboo + 1, a, b + L[bamboo], c))
		res = min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) if c > 0 else min(res, dfs(bamboo + 1, a, b, c + L[bamboo]))
		res = min(res, dfs(bamboo + 1, a, b, c))
		return res

	print(dfs(0, 0, 0, 0)) main N, A, B, C = NMI() N NMI() NMI A B C NI() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) NI() NI L = [NI() for _ in range(N)] L [NI() for _ in range(N)] def dfs(bamboo, a, b, c):
		if bamboo == N:
			if a*b*c == 0:
				return 10**100
			a, b, c = sorted([a, b, c], reverse=True)
			res = abs(A-a) + abs(B-b) + abs(C-c)
			return res

		res = 10**100

		res = min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) if a > 0 else min(res, dfs(bamboo + 1, a + L[bamboo], b, c))
		res = min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) if b > 0 else min(res, dfs(bamboo + 1, a, b + L[bamboo], c))
		res = min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) if c > 0 else min(res, dfs(bamboo + 1, a, b, c + L[bamboo]))
		res = min(res, dfs(bamboo + 1, a, b, c))
		return res

	 dfs if bamboo == N:
			if a*b*c == 0:
				return 10**100
			a, b, c = sorted([a, b, c], reverse=True)
			res = abs(A-a) + abs(B-b) + abs(C-c)
			return res

		 bamboo == N bamboo N if a*b*c == 0:
				return 10**100
			 a*b*c == 0 a*b*c a*b a b c 0 return 10**100 10**100 10 100 a, b, c = sorted([a, b, c], reverse=True) a sorted([a, b, c], reverse=True) sorted [a, b, c] a b c reverse=True reverse True b c res = abs(A-a) + abs(B-b) + abs(C-c) res abs(A-a) + abs(B-b) + abs(C-c) abs(A-a) + abs(B-b) abs(A-a) abs A-a A a abs(B-b) abs B-b B b abs(C-c) abs C-c C c return res res res = 10**100 res 10**100 10 100 res = min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) if a > 0 else min(res, dfs(bamboo + 1, a + L[bamboo], b, c)) res min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) if a > 0 else min(res, dfs(bamboo + 1, a + L[bamboo], b, c)) a > 0 a 0 min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) min res dfs(bamboo + 1, a + L[bamboo], b, c) + 10 dfs(bamboo + 1, a + L[bamboo], b, c) dfs bamboo + 1 bamboo 1 a + L[bamboo] a L[bamboo] L bamboo b c 10 min(res, dfs(bamboo + 1, a + L[bamboo], b, c)) min res dfs(bamboo + 1, a + L[bamboo], b, c) dfs bamboo + 1 bamboo 1 a + L[bamboo] a L[bamboo] L bamboo b c res = min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) if b > 0 else min(res, dfs(bamboo + 1, a, b + L[bamboo], c)) res min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) if b > 0 else min(res, dfs(bamboo + 1, a, b + L[bamboo], c)) b > 0 b 0 min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) min res dfs(bamboo + 1, a, b + L[bamboo], c) + 10 dfs(bamboo + 1, a, b + L[bamboo], c) dfs bamboo + 1 bamboo 1 a b + L[bamboo] b L[bamboo] L bamboo c 10 min(res, dfs(bamboo + 1, a, b + L[bamboo], c)) min res dfs(bamboo + 1, a, b + L[bamboo], c) dfs bamboo + 1 bamboo 1 a b + L[bamboo] b L[bamboo] L bamboo c res = min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) if c > 0 else min(res, dfs(bamboo + 1, a, b, c + L[bamboo])) res min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) if c > 0 else min(res, dfs(bamboo + 1, a, b, c + L[bamboo])) c > 0 c 0 min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) min res dfs(bamboo + 1, a, b, c + L[bamboo]) + 10 dfs(bamboo + 1, a, b, c + L[bamboo]) dfs bamboo + 1 bamboo 1 a b c + L[bamboo] c L[bamboo] L bamboo 10 min(res, dfs(bamboo + 1, a, b, c + L[bamboo])) min res dfs(bamboo + 1, a, b, c + L[bamboo]) dfs bamboo + 1 bamboo 1 a b c + L[bamboo] c L[bamboo] L bamboo res = min(res, dfs(bamboo + 1, a, b, c)) res min(res, dfs(bamboo + 1, a, b, c)) min res dfs(bamboo + 1, a, b, c) dfs bamboo + 1 bamboo 1 a b c return res res bamboo bamboo a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 if __name__ == "__main__":
	main() __name__ == "__main__" __name__ "__main__" main() main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] make_grid NLI = lambda: list(NMI()) lambda: list(NMI()) NLI NMI = lambda: map(int, input().split()) lambda: map(int, input().split()) NMI SI = lambda: input() lambda: input() SI input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input NI = lambda: int(input()) lambda: int(input()) NI def main():
	N, A, B, C = NMI()
	L = [NI() for _ in range(N)]

	def dfs(bamboo, a, b, c):
		if bamboo == N:
			if a*b*c == 0:
				return 10**100
			a, b, c = sorted([a, b, c], reverse=True)
			res = abs(A-a) + abs(B-b) + abs(C-c)
			return res

		res = 10**100

		res = min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) if a > 0 else min(res, dfs(bamboo + 1, a + L[bamboo], b, c))
		res = min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) if b > 0 else min(res, dfs(bamboo + 1, a, b + L[bamboo], c))
		res = min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) if c > 0 else min(res, dfs(bamboo + 1, a, b, c + L[bamboo]))
		res = min(res, dfs(bamboo + 1, a, b, c))
		return res

	print(dfs(0, 0, 0, 0)) def main():
	N, A, B, C = NMI()
	L = [NI() for _ in range(N)]

	def dfs(bamboo, a, b, c):
		if bamboo == N:
			if a*b*c == 0:
				return 10**100
			a, b, c = sorted([a, b, c], reverse=True)
			res = abs(A-a) + abs(B-b) + abs(C-c)
			return res

		res = 10**100

		res = min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) if a > 0 else min(res, dfs(bamboo + 1, a + L[bamboo], b, c))
		res = min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) if b > 0 else min(res, dfs(bamboo + 1, a, b + L[bamboo], c))
		res = min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) if c > 0 else min(res, dfs(bamboo + 1, a, b, c + L[bamboo]))
		res = min(res, dfs(bamboo + 1, a, b, c))
		return res

	print(dfs(0, 0, 0, 0)) main
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
	N, A, B, C = NMI()
	L = [NI() for _ in range(N)]

	def dfs(bamboo, a, b, c):
		if bamboo == N:
			if a*b*c == 0:
				return 10**100
			a, b, c = sorted([a, b, c], reverse=True)
			res = abs(A-a) + abs(B-b) + abs(C-c)
			return res

		res = 10**100

		res = min(res, dfs(bamboo + 1, a + L[bamboo], b, c) + 10) if a > 0 else min(res, dfs(bamboo + 1, a + L[bamboo], b, c))
		res = min(res, dfs(bamboo + 1, a, b + L[bamboo], c) + 10) if b > 0 else min(res, dfs(bamboo + 1, a, b + L[bamboo], c))
		res = min(res, dfs(bamboo + 1, a, b, c + L[bamboo]) + 10) if c > 0 else min(res, dfs(bamboo + 1, a, b, c + L[bamboo]))
		res = min(res, dfs(bamboo + 1, a, b, c))
		return res

	print(dfs(0, 0, 0, 0))



if __name__ == "__main__":
	main()