from itertools import permutations
from copy import deepcopy
from collections import Counter

n,a,b,c = map(int,input().split())
take = []
for _ in range(n):
	take.append(int(input()))
tmp = deepcopy(take)
ans_list = []

sum_abc = 10 ** 5
for abc in permutations([a,b,c],3):
	take = deepcopy(tmp)
	ans = 0
	l = []
	l2 = []
	s = Counter(take)
	#print(s)
	for x in abc:
		res = []
		l2 = []
		take = []
		for i,num in s.items():
			for j in range(num):
				take.append(i)
		#take = list(s)
		for i in range(2**n):
			l = []
			for j in range(len(take)):
					if i & (1<<j):
						l.append(take[j])
			if len(l) == 0:
				continue
			res.append(10*(len(l)-1) + abs(sum(l) - x))
			l2.append(l)
		minimum = sum_abc
		for i in range(len(res)):
			if minimum > res[i]:
				minimum = res[i]
				s2 = l2[i]
		for i in range(len(s2)):
			s[s2[i]] -= 1
			if s[s2[i]] == 0:
				s.pop(s2[i])
		#s = s - s2
		ans += minimum
		#print(res,s,minimum)
	ans_list.append(ans)

print(min(ans_list)) from itertools import permutations from copy import deepcopy from collections import Counter n,a,b,c = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split a b c take = [] take [] for _ in range(n):
	take.append(int(input())) _ range(n) range n take.append(int(input())) take.append take append int(input()) int input() input tmp = deepcopy(take) tmp deepcopy(take) deepcopy take ans_list = [] ans_list [] sum_abc = 10 ** 5 sum_abc 10 ** 5 10 5 for abc in permutations([a,b,c],3):
	take = deepcopy(tmp)
	ans = 0
	l = []
	l2 = []
	s = Counter(take)
	#print(s)
	for x in abc:
		res = []
		l2 = []
		take = []
		for i,num in s.items():
			for j in range(num):
				take.append(i)
		#take = list(s)
		for i in range(2**n):
			l = []
			for j in range(len(take)):
					if i & (1<<j):
						l.append(take[j])
			if len(l) == 0:
				continue
			res.append(10*(len(l)-1) + abs(sum(l) - x))
			l2.append(l)
		minimum = sum_abc
		for i in range(len(res)):
			if minimum > res[i]:
				minimum = res[i]
				s2 = l2[i]
		for i in range(len(s2)):
			s[s2[i]] -= 1
			if s[s2[i]] == 0:
				s.pop(s2[i])
		#s = s - s2
		ans += minimum
		#print(res,s,minimum)
	ans_list.append(ans) abc permutations([a,b,c],3) permutations [a,b,c] a b c 3 take = deepcopy(tmp) take deepcopy(tmp) deepcopy tmp ans = 0 ans 0 l = [] l [] l2 = [] l2 [] s = Counter(take) s Counter(take) Counter take for x in abc:
		res = []
		l2 = []
		take = []
		for i,num in s.items():
			for j in range(num):
				take.append(i)
		#take = list(s)
		for i in range(2**n):
			l = []
			for j in range(len(take)):
					if i & (1<<j):
						l.append(take[j])
			if len(l) == 0:
				continue
			res.append(10*(len(l)-1) + abs(sum(l) - x))
			l2.append(l)
		minimum = sum_abc
		for i in range(len(res)):
			if minimum > res[i]:
				minimum = res[i]
				s2 = l2[i]
		for i in range(len(s2)):
			s[s2[i]] -= 1
			if s[s2[i]] == 0:
				s.pop(s2[i])
		#s = s - s2
		ans += minimum
		#print(res,s,minimum)
	 x abc res = [] res [] l2 = [] l2 [] take = [] take [] for i,num in s.items():
			for j in range(num):
				take.append(i)
		#take = list(s)
		 i num s.items() s.items s items for j in range(num):
				take.append(i)
		#take = list(s)
		 j range(num) range num take.append(i) take.append take append i for i in range(2**n):
			l = []
			for j in range(len(take)):
					if i & (1<<j):
						l.append(take[j])
			if len(l) == 0:
				continue
			res.append(10*(len(l)-1) + abs(sum(l) - x))
			l2.append(l)
		 i range(2**n) range 2**n 2 n l = [] l [] for j in range(len(take)):
					if i & (1<<j):
						l.append(take[j])
			 j range(len(take)) range len(take) len take if i & (1<<j):
						l.append(take[j])
			 i & (1<<j) i 1<<j 1 j l.append(take[j]) l.append l append take[j] take j if len(l) == 0:
				continue
			 len(l) == 0 len(l) len l 0 continue res.append(10*(len(l)-1) + abs(sum(l) - x)) res.append res append 10*(len(l)-1) + abs(sum(l) - x) 10*(len(l)-1) 10 len(l)-1 len(l) len l 1 abs(sum(l) - x) abs sum(l) - x sum(l) sum l x l2.append(l) l2.append l2 append l minimum = sum_abc minimum sum_abc for i in range(len(res)):
			if minimum > res[i]:
				minimum = res[i]
				s2 = l2[i]
		 i range(len(res)) range len(res) len res if minimum > res[i]:
				minimum = res[i]
				s2 = l2[i]
		 minimum > res[i] minimum res[i] res i minimum = res[i] minimum res[i] res i s2 = l2[i] s2 l2[i] l2 i for i in range(len(s2)):
			s[s2[i]] -= 1
			if s[s2[i]] == 0:
				s.pop(s2[i])
		#s = s - s2
		 i range(len(s2)) range len(s2) len s2 s[s2[i]] -= 1 s[s2[i]] s s2[i] s2 i 1 if s[s2[i]] == 0:
				s.pop(s2[i])
		#s = s - s2
		 s[s2[i]] == 0 s[s2[i]] s s2[i] s2 i 0 s.pop(s2[i]) s.pop s pop s2[i] s2 i ans += minimum ans minimum ans_list.append(ans) ans_list.append ans_list append ans print(min(ans_list)) print min(ans_list) min ans_list tmp = deepcopy(take) deepcopy(take) tmp ans_list = [] [] ans_list l = [] [] l c = map(int,input().split()) map(int,input().split()) c minimum = sum_abc sum_abc minimum l = [] [] l s = Counter(take) Counter(take) s n,a,b,c = map(int,input().split()) map(int,input().split()) n take = [] [] take l2 = [] [] l2 minimum = res[i] res[i] minimum a,b,c = map(int,input().split()) map(int,input().split()) a ans = 0 0 ans b,c = map(int,input().split()) map(int,input().split()) b l2 = [] [] l2 ans += minimum minimum ans s2 = l2[i] l2[i] s2 res = [] [] res sum_abc = 10 ** 5 10 ** 5 sum_abc take = deepcopy(tmp) deepcopy(tmp) take take = [] [] take
from itertools import permutations
from copy import deepcopy
from collections import Counter

n,a,b,c = map(int,input().split())
take = []
for _ in range(n):
	take.append(int(input()))
tmp = deepcopy(take)
ans_list = []

sum_abc = 10 ** 5
for abc in permutations([a,b,c],3):
	take = deepcopy(tmp)
	ans = 0
	l = []
	l2 = []
	s = Counter(take)
	#print(s)
	for x in abc:
		res = []
		l2 = []
		take = []
		for i,num in s.items():
			for j in range(num):
				take.append(i)
		#take = list(s)
		for i in range(2**n):
			l = []
			for j in range(len(take)):
					if i & (1<<j):
						l.append(take[j])
			if len(l) == 0:
				continue
			res.append(10*(len(l)-1) + abs(sum(l) - x))
			l2.append(l)
		minimum = sum_abc
		for i in range(len(res)):
			if minimum > res[i]:
				minimum = res[i]
				s2 = l2[i]
		for i in range(len(s2)):
			s[s2[i]] -= 1
			if s[s2[i]] == 0:
				s.pop(s2[i])
		#s = s - s2
		ans += minimum
		#print(res,s,minimum)
	ans_list.append(ans)

print(min(ans_list))
