N,A,B,C = map(int,input().split())
l = []
for i in range(N):
  l.append(int(input()))
l.sort()

def tots(X, n):
    if (int(X/n)):
        return tots(int(X/n), n)+str(X%n)
    return str(X%n)

tnum = 0
ans = float("inf")
target = [A,B,C]
for i in range(4**N):
  #N本の竹の行き先の振り分け
  wake = [[],[],[],[]]
  ts = "0"*(N-len(tots(i,4)))+tots(i,4)
  for j in range(N):
    wake[int(ts[j])].append(l[j])
  if 0 == len(wake[0]) or 0 == len(wake[1]) or 0 == len(wake[2]):
    continue 
  #合成して行き先との長さの差をたしわせる
  c = 0
  for j in range(3):
    c +=abs(target[j] - sum(wake[j]))      
  tnum = len(wake[0])+len(wake[1])+len(wake[2])
  ans = min(ans,c+10*(tnum-3))  

if A in l and B in l and C in l:
  ans = 0
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 l = [] l [] for i in range(N):
  l.append(int(input())) i range(N) range N l.append(int(input())) l.append l append int(input()) int input() input l.sort() l.sort l sort def tots(X, n):
    if (int(X/n)):
        return tots(int(X/n), n)+str(X%n)
    return str(X%n) tots if (int(X/n)):
        return tots(int(X/n), n)+str(X%n)
     int(X/n) int X/n X n return tots(int(X/n), n)+str(X%n) tots(int(X/n), n)+str(X%n) tots(int(X/n), n) tots int(X/n) int X/n X n n str(X%n) str X%n X n return str(X%n) str(X%n) str X%n X n X X n n tnum = 0 tnum 0 ans = float("inf") ans float("inf") float "inf" target = [A,B,C] target [A,B,C] A B C for i in range(4**N):
  #N本の竹の行き先の振り分け
  wake = [[],[],[],[]]
  ts = "0"*(N-len(tots(i,4)))+tots(i,4)
  for j in range(N):
    wake[int(ts[j])].append(l[j])
  if 0 == len(wake[0]) or 0 == len(wake[1]) or 0 == len(wake[2]):
    continue 
  #合成して行き先との長さの差をたしわせる
  c = 0
  for j in range(3):
    c +=abs(target[j] - sum(wake[j]))      
  tnum = len(wake[0])+len(wake[1])+len(wake[2])
  ans = min(ans,c+10*(tnum-3))   i range(4**N) range 4**N 4 N wake = [[],[],[],[]] wake [[],[],[],[]] [] [] [] [] ts = "0"*(N-len(tots(i,4)))+tots(i,4) ts "0"*(N-len(tots(i,4)))+tots(i,4) "0"*(N-len(tots(i,4))) "0" N-len(tots(i,4)) N len(tots(i,4)) len tots(i,4) tots i 4 tots(i,4) tots i 4 for j in range(N):
    wake[int(ts[j])].append(l[j])
   j range(N) range N wake[int(ts[j])].append(l[j]) [int(ts[j])].append [int(ts[j])] wake int(ts[j]) int ts[j] ts j append l[j] l j if 0 == len(wake[0]) or 0 == len(wake[1]) or 0 == len(wake[2]):
    continue 
  #合成して行き先との長さの差をたしわせる
   0 == len(wake[0]) or 0 == len(wake[1]) or 0 == len(wake[2]) 0 == len(wake[0]) or 0 == len(wake[1]) 0 == len(wake[0]) 0 len(wake[0]) len wake[0] wake 0 0 == len(wake[1]) 0 len(wake[1]) len wake[1] wake 1 0 == len(wake[2]) 0 len(wake[2]) len wake[2] wake 2 continue c = 0 c 0 for j in range(3):
    c +=abs(target[j] - sum(wake[j]))      
   j range(3) range 3 c +=abs(target[j] - sum(wake[j])) c abs(target[j] - sum(wake[j])) abs target[j] - sum(wake[j]) target[j] target j sum(wake[j]) sum wake[j] wake j tnum = len(wake[0])+len(wake[1])+len(wake[2]) tnum len(wake[0])+len(wake[1])+len(wake[2]) len(wake[0])+len(wake[1]) len(wake[0]) len wake[0] wake 0 len(wake[1]) len wake[1] wake 1 len(wake[2]) len wake[2] wake 2 ans = min(ans,c+10*(tnum-3)) ans min(ans,c+10*(tnum-3)) min ans c+10*(tnum-3) c 10*(tnum-3) 10 tnum-3 tnum 3 if A in l and B in l and C in l:
  ans = 0 A in l and B in l and C in l A in l and B in l A in l A l B in l B l C in l C l ans = 0 ans 0 print(ans) print ans def tots(X, n):
    if (int(X/n)):
        return tots(int(X/n), n)+str(X%n)
    return str(X%n) def tots(X, n):
    if (int(X/n)):
        return tots(int(X/n), n)+str(X%n)
    return str(X%n) tots c = 0 0 c target = [A,B,C] [A,B,C] target N,A,B,C = map(int,input().split()) map(int,input().split()) N l = [] [] l ts = "0"*(N-len(tots(i,4)))+tots(i,4) "0"*(N-len(tots(i,4)))+tots(i,4) ts c +=abs(target[j] - sum(wake[j])) abs(target[j] - sum(wake[j])) c ans = 0 0 ans B,C = map(int,input().split()) map(int,input().split()) B wake = [[],[],[],[]] [[],[],[],[]] wake tnum = len(wake[0])+len(wake[1])+len(wake[2]) len(wake[0])+len(wake[1])+len(wake[2]) tnum ans = float("inf") float("inf") ans C = map(int,input().split()) map(int,input().split()) C tnum = 0 0 tnum A,B,C = map(int,input().split()) map(int,input().split()) A ans = min(ans,c+10*(tnum-3)) min(ans,c+10*(tnum-3)) ans
N,A,B,C = map(int,input().split())
l = []
for i in range(N):
  l.append(int(input()))
l.sort()

def tots(X, n):
    if (int(X/n)):
        return tots(int(X/n), n)+str(X%n)
    return str(X%n)

tnum = 0
ans = float("inf")
target = [A,B,C]
for i in range(4**N):
  #N本の竹の行き先の振り分け
  wake = [[],[],[],[]]
  ts = "0"*(N-len(tots(i,4)))+tots(i,4)
  for j in range(N):
    wake[int(ts[j])].append(l[j])
  if 0 == len(wake[0]) or 0 == len(wake[1]) or 0 == len(wake[2]):
    continue 
  #合成して行き先との長さの差をたしわせる
  c = 0
  for j in range(3):
    c +=abs(target[j] - sum(wake[j]))      
  tnum = len(wake[0])+len(wake[1])+len(wake[2])
  ans = min(ans,c+10*(tnum-3))  

if A in l and B in l and C in l:
  ans = 0
print(ans)  