n,a,b,c = map(int, input().split())

l = [int(input()) for i in range(n)]

import itertools

bumboo=["A","B","C","D"]

prod = list(itertools.product(bumboo,repeat=n))

temp = []

for i in prod:
    tempa = 0
    tempb = 0
    tempc = 0
    for j in range(n):
        if i[j] =="A":
            tempa += l[j]
        elif i[j] =="B":
            tempb += l[j]
        elif i[j] =="C":
            tempc += l[j]
    if tempa*tempb*tempc == 0:
        pass
    else:
        temp.append(abs(tempa-a)+abs(tempb-b)+abs(tempc-c)+10*(n-3-i.count("D")))
print(min(temp)) n,a,b,c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input l = [int(input()) for i in range(n)] l [int(input()) for i in range(n)] import itertools itertools bumboo=["A","B","C","D"] bumboo ["A","B","C","D"] "A" "B" "C" "D" prod = list(itertools.product(bumboo,repeat=n)) prod list(itertools.product(bumboo,repeat=n)) list itertools.product(bumboo,repeat=n) itertools.product itertools product bumboo repeat=n repeat n temp = [] temp [] for i in prod:
    tempa = 0
    tempb = 0
    tempc = 0
    for j in range(n):
        if i[j] =="A":
            tempa += l[j]
        elif i[j] =="B":
            tempb += l[j]
        elif i[j] =="C":
            tempc += l[j]
    if tempa*tempb*tempc == 0:
        pass
    else:
        temp.append(abs(tempa-a)+abs(tempb-b)+abs(tempc-c)+10*(n-3-i.count("D"))) i prod tempa = 0 tempa 0 tempb = 0 tempb 0 tempc = 0 tempc 0 for j in range(n):
        if i[j] =="A":
            tempa += l[j]
        elif i[j] =="B":
            tempb += l[j]
        elif i[j] =="C":
            tempc += l[j]
     j range(n) range n if i[j] =="A":
            tempa += l[j]
        elif i[j] =="B":
            tempb += l[j]
        elif i[j] =="C":
            tempc += l[j]
     i[j] =="A" i[j] i j "A" tempa += l[j] tempa l[j] l j elif i[j] =="B":
            tempb += l[j]
         i[j] =="B" i[j] i j "B" tempb += l[j] tempb l[j] l j elif i[j] =="C":
            tempc += l[j]
     i[j] =="C" i[j] i j "C" tempc += l[j] tempc l[j] l j if tempa*tempb*tempc == 0:
        pass
    else:
        temp.append(abs(tempa-a)+abs(tempb-b)+abs(tempc-c)+10*(n-3-i.count("D"))) tempa*tempb*tempc == 0 tempa*tempb*tempc tempa*tempb tempa tempb tempc 0 temp.append(abs(tempa-a)+abs(tempb-b)+abs(tempc-c)+10*(n-3-i.count("D"))) temp.append temp append abs(tempa-a)+abs(tempb-b)+abs(tempc-c)+10*(n-3-i.count("D")) abs(tempa-a)+abs(tempb-b)+abs(tempc-c) abs(tempa-a)+abs(tempb-b) abs(tempa-a) abs tempa-a tempa a abs(tempb-b) abs tempb-b tempb b abs(tempc-c) abs tempc-c tempc c 10*(n-3-i.count("D")) 10 n-3-i.count("D") n-3 n 3 i.count("D") i.count i count "D" print(min(temp)) print min(temp) min temp tempa += l[j] l[j] tempa tempb += l[j] l[j] tempb a,b,c = map(int, input().split()) map(int, input().split()) a tempb = 0 0 tempb tempc = 0 0 tempc n,a,b,c = map(int, input().split()) map(int, input().split()) n b,c = map(int, input().split()) map(int, input().split()) b bumboo=["A","B","C","D"] ["A","B","C","D"] bumboo tempc += l[j] l[j] tempc prod = list(itertools.product(bumboo,repeat=n)) list(itertools.product(bumboo,repeat=n)) prod temp = [] [] temp l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l c = map(int, input().split()) map(int, input().split()) c tempa = 0 0 tempa
n,a,b,c = map(int, input().split())

l = [int(input()) for i in range(n)]

import itertools

bumboo=["A","B","C","D"]

prod = list(itertools.product(bumboo,repeat=n))

temp = []

for i in prod:
    tempa = 0
    tempb = 0
    tempc = 0
    for j in range(n):
        if i[j] =="A":
            tempa += l[j]
        elif i[j] =="B":
            tempb += l[j]
        elif i[j] =="C":
            tempc += l[j]
    if tempa*tempb*tempc == 0:
        pass
    else:
        temp.append(abs(tempa-a)+abs(tempb-b)+abs(tempc-c)+10*(n-3-i.count("D")))
print(min(temp))