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

import itertools
kouho=list(itertools.product(range(4), repeat=n))
ans=10**9
for item in kouho:

    if 0 in item and 1 in item and 2 in item:
        cost=0
        abc=[0]*3

        for i,v in enumerate(item):
            if v<3:
                if abc[v]>0:
                    cost+=10
                abc[v]+=l[i]

        for i in range(3):
            cost+=abs(abc[i]-ABC[i])
        #print(item,cost)
        ans=min(ans,cost)

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)] ABC=(a,b,c) ABC (a,b,c) a b c import itertools itertools kouho=list(itertools.product(range(4), repeat=n)) kouho list(itertools.product(range(4), repeat=n)) list itertools.product(range(4), repeat=n) itertools.product itertools product range(4) range 4 repeat=n repeat n ans=10**9 ans 10**9 10 9 for item in kouho:

    if 0 in item and 1 in item and 2 in item:
        cost=0
        abc=[0]*3

        for i,v in enumerate(item):
            if v<3:
                if abc[v]>0:
                    cost+=10
                abc[v]+=l[i]

        for i in range(3):
            cost+=abs(abc[i]-ABC[i])
        #print(item,cost)
        ans=min(ans,cost) item kouho if 0 in item and 1 in item and 2 in item:
        cost=0
        abc=[0]*3

        for i,v in enumerate(item):
            if v<3:
                if abc[v]>0:
                    cost+=10
                abc[v]+=l[i]

        for i in range(3):
            cost+=abs(abc[i]-ABC[i])
        #print(item,cost)
        ans=min(ans,cost) 0 in item and 1 in item and 2 in item 0 in item and 1 in item 0 in item 0 item 1 in item 1 item 2 in item 2 item cost=0 cost 0 abc=[0]*3 abc [0]*3 [0] 0 3 for i,v in enumerate(item):
            if v<3:
                if abc[v]>0:
                    cost+=10
                abc[v]+=l[i]

         i v enumerate(item) enumerate item if v<3:
                if abc[v]>0:
                    cost+=10
                abc[v]+=l[i]

         v<3 v 3 if abc[v]>0:
                    cost+=10
                 abc[v]>0 abc[v] abc v 0 cost+=10 cost 10 abc[v]+=l[i] abc[v] abc v l[i] l i for i in range(3):
            cost+=abs(abc[i]-ABC[i])
        #print(item,cost)
         i range(3) range 3 cost+=abs(abc[i]-ABC[i]) cost abs(abc[i]-ABC[i]) abs abc[i]-ABC[i] abc[i] abc i ABC[i] ABC i ans=min(ans,cost) ans min(ans,cost) min ans cost print(ans) print ans cost+=abs(abc[i]-ABC[i]) abs(abc[i]-ABC[i]) cost cost=0 0 cost b,c=map(int,input().split()) map(int,input().split()) b ans=min(ans,cost) min(ans,cost) ans n,a,b,c=map(int,input().split()) map(int,input().split()) n kouho=list(itertools.product(range(4), repeat=n)) list(itertools.product(range(4), repeat=n)) kouho l=[int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l abc=[0]*3 [0]*3 abc ABC=(a,b,c) (a,b,c) ABC cost+=10 10 cost a,b,c=map(int,input().split()) map(int,input().split()) a c=map(int,input().split()) map(int,input().split()) c ans=10**9 10**9 ans
n,a,b,c=map(int,input().split())
l=[int(input()) for _ in range(n)]
ABC=(a,b,c)

import itertools
kouho=list(itertools.product(range(4), repeat=n))
ans=10**9
for item in kouho:

    if 0 in item and 1 in item and 2 in item:
        cost=0
        abc=[0]*3

        for i,v in enumerate(item):
            if v<3:
                if abc[v]>0:
                    cost+=10
                abc[v]+=l[i]

        for i in range(3):
            cost+=abs(abc[i]-ABC[i])
        #print(item,cost)
        ans=min(ans,cost)

print(ans)


    
    












        
