n, a, b, c = map(int, input().split())
L = [int(input()) for _ in range(n)]

ans = float("inf")
for i in range(4**n):
  T = [0]*4
  C = [0]*4
  for j, l in enumerate(L):
    T[(i>>(2*j))&3] += l
    C[(i>>(2*j))&3] += 1
  ta, tb, tc = T[1:]
  if ta == 0 or tb == 0 or tc == 0:
    continue
  temp = 0
  temp += max(C[1]-1, 0)
  temp += max(C[2]-1, 0)
  temp += max(C[3]-1, 0)
  temp *= 10
  temp += abs(a-ta) + abs(b-tb) + abs(c-tc)
  ans = min(ans, temp)
print(ans) n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input L = [int(input()) for _ in range(n)] L [int(input()) for _ in range(n)] ans = float("inf") ans float("inf") float "inf" for i in range(4**n):
  T = [0]*4
  C = [0]*4
  for j, l in enumerate(L):
    T[(i>>(2*j))&3] += l
    C[(i>>(2*j))&3] += 1
  ta, tb, tc = T[1:]
  if ta == 0 or tb == 0 or tc == 0:
    continue
  temp = 0
  temp += max(C[1]-1, 0)
  temp += max(C[2]-1, 0)
  temp += max(C[3]-1, 0)
  temp *= 10
  temp += abs(a-ta) + abs(b-tb) + abs(c-tc)
  ans = min(ans, temp) i range(4**n) range 4**n 4 n T = [0]*4 T [0]*4 [0] 0 4 C = [0]*4 C [0]*4 [0] 0 4 for j, l in enumerate(L):
    T[(i>>(2*j))&3] += l
    C[(i>>(2*j))&3] += 1
   j l enumerate(L) enumerate L T[(i>>(2*j))&3] += l T[(i>>(2*j))&3] T (i>>(2*j))&3 i>>(2*j) i 2*j 2 j 3 l C[(i>>(2*j))&3] += 1 C[(i>>(2*j))&3] C (i>>(2*j))&3 i>>(2*j) i 2*j 2 j 3 1 ta, tb, tc = T[1:] ta T[1:] T 1: 1 tb tc if ta == 0 or tb == 0 or tc == 0:
    continue
   ta == 0 or tb == 0 or tc == 0 ta == 0 or tb == 0 ta == 0 ta 0 tb == 0 tb 0 tc == 0 tc 0 continue temp = 0 temp 0 temp += max(C[1]-1, 0) temp max(C[1]-1, 0) max C[1]-1 C[1] C 1 1 0 temp += max(C[2]-1, 0) temp max(C[2]-1, 0) max C[2]-1 C[2] C 2 1 0 temp += max(C[3]-1, 0) temp max(C[3]-1, 0) max C[3]-1 C[3] C 3 1 0 temp *= 10 temp 10 temp += abs(a-ta) + abs(b-tb) + abs(c-tc) temp abs(a-ta) + abs(b-tb) + abs(c-tc) abs(a-ta) + abs(b-tb) abs(a-ta) abs a-ta a ta abs(b-tb) abs b-tb b tb abs(c-tc) abs c-tc c tc ans = min(ans, temp) ans min(ans, temp) min ans temp print(ans) print ans L = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] L C = [0]*4 [0]*4 C temp += max(C[3]-1, 0) max(C[3]-1, 0) temp a, b, c = map(int, input().split()) map(int, input().split()) a ans = min(ans, temp) min(ans, temp) ans tc = T[1:] T[1:] tc temp = 0 0 temp T = [0]*4 [0]*4 T ta, tb, tc = T[1:] T[1:] ta b, c = map(int, input().split()) map(int, input().split()) b ans = float("inf") float("inf") ans temp += max(C[2]-1, 0) max(C[2]-1, 0) temp c = map(int, input().split()) map(int, input().split()) c temp *= 10 10 temp n, a, b, c = map(int, input().split()) map(int, input().split()) n tb, tc = T[1:] T[1:] tb temp += max(C[1]-1, 0) max(C[1]-1, 0) temp temp += abs(a-ta) + abs(b-tb) + abs(c-tc) abs(a-ta) + abs(b-tb) + abs(c-tc) temp
n, a, b, c = map(int, input().split())
L = [int(input()) for _ in range(n)]

ans = float("inf")
for i in range(4**n):
  T = [0]*4
  C = [0]*4
  for j, l in enumerate(L):
    T[(i>>(2*j))&3] += l
    C[(i>>(2*j))&3] += 1
  ta, tb, tc = T[1:]
  if ta == 0 or tb == 0 or tc == 0:
    continue
  temp = 0
  temp += max(C[1]-1, 0)
  temp += max(C[2]-1, 0)
  temp += max(C[3]-1, 0)
  temp *= 10
  temp += abs(a-ta) + abs(b-tb) + abs(c-tc)
  ans = min(ans, temp)
print(ans)