import itertools
N,A,B,C=map(int,input().split())
l=list()
for i in range(N):
    l.append(int(input()))


def solve(x,ans,m):
    global N,A,B,C,l
    c=[10000,-1]
    for i in  range(0,len(l)):
        if(abs(l[i]-x)<=10 and abs(l[i]-x)<=c[0]):
            c[0]=abs(l[i]-x)
            c[1]=i
    
    if(c[1]!=-1):
        tmp=l[c[1]]
        l.pop(c[1])
        return(ans+abs(tmp-x))
    else:
        mins=100000
        minstmp=[0,0]
        for i in range(0,len(l)):
            if(mins<abs(x-l[i])):
                pass
            else:
                minstmp=[i,i]
                mins=abs(x-l[i])-10
        check=False
    
        for i in itertools.combinations(l,2):
            tmp=i[0]+i[1]
            if(abs(x-tmp)<mins):
                mins=abs(x-tmp)
                minstmp=[i[0],i[1]]
                check=True
        if(check and len(l)-1>m):
            ans+=10
            l.append(minstmp[0]+minstmp[1])
            l.remove(minstmp[0])
            l.remove(minstmp[1])
            return solve(x,ans,m)
        else:
            mins=100000
            minstmp=[0,0]
            for i in range(0,len(l)):
                
                if(mins<abs(x-l[i])):
                    pass
                else:
                    minstmp=[i,i]
                    mins=abs(x-l[i])-10
            l.pop(minstmp[0])
            return(ans+mins+10)


totalAns=1000000000
import copy
L=copy.deepcopy(l)

ans=0
ans+=solve(A,0,2)
ans+=solve(B,0,1)
ans+=solve(C,0,0)
if(ans<totalAns):
    totalAns=ans

l=copy.deepcopy(L)
ans=0
ans+=solve(A,0,2)
ans+=solve(C,0,1)
ans+=solve(B,0,0)
if(ans<totalAns):
    totalAns=ans

l=copy.deepcopy(L)
ans=0
ans+=solve(B,0,2)
ans+=solve(A,0,1)
ans+=solve(C,0,0)
if(ans<totalAns):
    totalAns=ans

l=copy.deepcopy(L)
ans=0
ans+=solve(B,0,2)
ans+=solve(C,0,1)
ans+=solve(A,0,0)
if(ans<totalAns):
    totalAns=ans

l=copy.deepcopy(L)
ans=0
ans+=solve(C,0,2)
ans+=solve(A,0,1)
ans+=solve(B,0,0)
if(ans<totalAns):
    totalAns=ans

l=copy.deepcopy(L)
ans=0
ans+=solve(C,0,2)
ans+=solve(B,0,1)
ans+=solve(A,0,0)
if(ans<totalAns):
    totalAns=ans

print(totalAns)