n,a,b,c, = map(int,input().split())
bb = [int(input()) for i in range(n)]
res = []
for j in range (4**n-1) :
  t = str(bin(j))
  tt = t[2:]
  ttt = "0" * (2*n-len(tt)) + tt
  tttt = tuple(ttt)
  ttttt = tuple(map (int,tttt))
  mp = 0
  ans = 10000000
  lg = [0,0,0,0]
  for take in range(n) :
      use = ttttt[take*2]*2 + ttttt[take*2+1]
      mp += 10
      if lg[use] == 0:
          mp -= 10
      lg[use] += bb[take]
      lg[3] = 0 
  mp += abs(a-lg[0])
  mp += abs(b-lg[1])
  mp += abs(c-lg[2])
  if ans > mp :
      ans = mp
  res.append(ans)
print (min(res))