n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
op=[[0],[1],[2]]
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
        tmp.append(j+[2])
    op=tmp
ans=1000000000
for i in op:
    ta=0
    tb=0
    tc=0
    for j in range(len(i)):
        if i[j]==0:
            ta+=l[j]
        elif i[j]==1:
            tb+=l[j]
        else:
            tc+=l[j]
    mp=abs(a-ta)+abs(b-tb)+abs(c-tc)
    if ta==0 or tb==0 or tc==0:
        mp=1000000000
    ans=min(ans,mp)
print(ans)