import itertools
n, a, b, c =map(int, input().split())
ans = float("inf")
take = [int(input()) for i in range(n)]

for pattern in itertools.product(range(4), repeat=n):
    abc = [0]*3
    mp=0
    for i in range(n):
      if pattern[i]==3:
        continue
      else:
        if abc[pattern[i]] != 0:
          mp+=10
        abc[pattern[i]]+=take[i]
    
    mp+=abs(a-abc[0])
    mp+=abs(b-abc[1])
    mp+=abs(c-abc[2])
    for i in range(3):
      if abc[i]==0:
        mp=float("inf")
        break
    ans = min(ans, mp)
    
print(ans) import itertools itertools n, a, b, c =map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c ans = float("inf") ans float("inf") float "inf" int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input take = [int(input()) for i in range(n)] take [int(input()) for i in range(n)] for pattern in itertools.product(range(4), repeat=n):
    abc = [0]*3
    mp=0
    for i in range(n):
      if pattern[i]==3:
        continue
      else:
        if abc[pattern[i]] != 0:
          mp+=10
        abc[pattern[i]]+=take[i]
    
    mp+=abs(a-abc[0])
    mp+=abs(b-abc[1])
    mp+=abs(c-abc[2])
    for i in range(3):
      if abc[i]==0:
        mp=float("inf")
        break
    ans = min(ans, mp)
     pattern itertools.product(range(4), repeat=n) itertools.product itertools product range(4) range 4 repeat=n repeat n abc = [0]*3 abc [0]*3 [0] 0 3 mp=0 mp 0 for i in range(n):
      if pattern[i]==3:
        continue
      else:
        if abc[pattern[i]] != 0:
          mp+=10
        abc[pattern[i]]+=take[i]
    
     i range(n) range n if pattern[i]==3:
        continue
      else:
        if abc[pattern[i]] != 0:
          mp+=10
        abc[pattern[i]]+=take[i]
    
     pattern[i]==3 pattern[i] pattern i 3 continue if abc[pattern[i]] != 0:
          mp+=10
         abc[pattern[i]] != 0 abc[pattern[i]] abc pattern[i] pattern i 0 mp+=10 mp 10 abc[pattern[i]]+=take[i] abc[pattern[i]] abc pattern[i] pattern i take[i] take i mp+=abs(a-abc[0]) mp abs(a-abc[0]) abs a-abc[0] a abc[0] abc 0 mp+=abs(b-abc[1]) mp abs(b-abc[1]) abs b-abc[1] b abc[1] abc 1 mp+=abs(c-abc[2]) mp abs(c-abc[2]) abs c-abc[2] c abc[2] abc 2 for i in range(3):
      if abc[i]==0:
        mp=float("inf")
        break
     i range(3) range 3 if abc[i]==0:
        mp=float("inf")
        break
     abc[i]==0 abc[i] abc i 0 mp=float("inf") mp float("inf") float "inf" break ans = min(ans, mp) ans min(ans, mp) min ans mp print(ans) print ans mp=0 0 mp mp+=abs(a-abc[0]) abs(a-abc[0]) mp ans = float("inf") float("inf") ans n, a, b, c =map(int, input().split()) map(int, input().split()) n mp+=10 10 mp c =map(int, input().split()) map(int, input().split()) c mp=float("inf") float("inf") mp abc = [0]*3 [0]*3 abc mp+=abs(b-abc[1]) abs(b-abc[1]) mp a, b, c =map(int, input().split()) map(int, input().split()) a take = [int(input()) for i in range(n)] [int(input()) for i in range(n)] take b, c =map(int, input().split()) map(int, input().split()) b mp+=abs(c-abc[2]) abs(c-abc[2]) mp ans = min(ans, mp) min(ans, mp) ans
import itertools
n, a, b, c =map(int, input().split())
ans = float("inf")
take = [int(input()) for i in range(n)]

for pattern in itertools.product(range(4), repeat=n):
    abc = [0]*3
    mp=0
    for i in range(n):
      if pattern[i]==3:
        continue
      else:
        if abc[pattern[i]] != 0:
          mp+=10
        abc[pattern[i]]+=take[i]
    
    mp+=abs(a-abc[0])
    mp+=abs(b-abc[1])
    mp+=abs(c-abc[2])
    for i in range(3):
      if abc[i]==0:
        mp=float("inf")
        break
    ans = min(ans, mp)
    
print(ans)
