
N,A,B,C=map(int,input().split())
L=[0]*(N)
for i in range(N):
    L[i]=int(input())
    

def calc(m):
    s=[0,0,0,0]
    sy=-3
    for i in range(N):
        s[m%4]+=L[i]
        if m%4!=0:
            sy+=1
        m=m//4
    for i in range(1,4):
        if s[i]==0:
            return 10**9
    return abs(A-s[1])+abs(B-s[2])+abs(C-s[3])+sy*10
    
ans=10**9
for i in range(pow(4,N)):
    ans=min(ans,calc(i))
print(ans)
    