N,A,B,C = map(int,input().split())

l = [int(input()) for _ in range(N)]

ans = 2 ** 20 -1
for i in range(N):
    for j in range(N):
        if i == j: continue
        for k in range(N):
            if i == k or j == k : continue
        
            x,y,z = l[i],l[j],l[k]
            cnt = 0
            
            for t in range(N):
                if t == i or t == j or t == k : continue

                if l[t] > 10:
                    cnt += l[t]
                    x += l[t]
                if l[t] > 10:
                    cnt += l[t]
                    y += l[t]
                if l[t] > 10:
                    cnt += l[t]
                    z += l[t]
            cnt += abs(x-A) 
            cnt += abs(y-B) 
            cnt += abs(z-C) 
            ans = min(ans,cnt)
                
                
print(ans)
        