N,*T = map(int,input().split())
L = [int(input()) for i in range(N)]
ans = 3000

for x in range(4**N):
    l = [0]*4
    t = [0]*4
    n = 4
    i = 0

    for i in range(N):
        l[x%n] += L[i]
        t[x%n] += 1
        x//=n

    if 0 in l[:3]:
        continue
    cost = 0
    for i in range(3):
        cost += (t[i]-1)*10
        cost += abs(l[i]-T[i])
    ans = min(ans, cost)

print(ans)
