from itertools import product
n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]

ans = float('inf')
for choice in product([0, 1, 2, 3], repeat=n):
    items = [0] * 3
    totals = [0] * 3
    temp = 0
    if min([choice.count(i) for i in range(3)]) == 0: continue
    for i, ch in enumerate(choice):
        if ch == 3: continue
        totals[ch] += l[i]
        items[ch] += 1
        if items[ch] > 1:
            temp += 10
    temp+=abs(a-totals[0])
    temp+=abs(b-totals[1])
    temp+=abs(c-totals[2])
    ans = min(ans, temp)
print(ans) from itertools import product 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)] ans = float('inf') ans float('inf') float 'inf' for choice in product([0, 1, 2, 3], repeat=n):
    items = [0] * 3
    totals = [0] * 3
    temp = 0
    if min([choice.count(i) for i in range(3)]) == 0: continue
    for i, ch in enumerate(choice):
        if ch == 3: continue
        totals[ch] += l[i]
        items[ch] += 1
        if items[ch] > 1:
            temp += 10
    temp+=abs(a-totals[0])
    temp+=abs(b-totals[1])
    temp+=abs(c-totals[2])
    ans = min(ans, temp) choice product([0, 1, 2, 3], repeat=n) product [0, 1, 2, 3] 0 1 2 3 repeat=n repeat n items = [0] * 3 items [0] * 3 [0] 0 3 totals = [0] * 3 totals [0] * 3 [0] 0 3 temp = 0 temp 0 choice.count(i) for i in range(3) for i in range(3) i range(3) range 3 for i in range(3) choice.count(i) choice.count choice count i if min([choice.count(i) for i in range(3)]) == 0: continue
     min([choice.count(i) for i in range(3)]) == 0 min([choice.count(i) for i in range(3)]) min [choice.count(i) for i in range(3)] 0 for i, ch in enumerate(choice):
        if ch == 3: continue
        totals[ch] += l[i]
        items[ch] += 1
        if items[ch] > 1:
            temp += 10
     i ch enumerate(choice) enumerate choice if ch == 3: continue
         ch == 3 ch 3 totals[ch] += l[i] totals[ch] totals ch l[i] l i items[ch] += 1 items[ch] items ch 1 if items[ch] > 1:
            temp += 10
     items[ch] > 1 items[ch] items ch 1 temp += 10 temp 10 temp+=abs(a-totals[0]) temp abs(a-totals[0]) abs a-totals[0] a totals[0] totals 0 temp+=abs(b-totals[1]) temp abs(b-totals[1]) abs b-totals[1] b totals[1] totals 1 temp+=abs(c-totals[2]) temp abs(c-totals[2]) abs c-totals[2] c totals[2] totals 2 ans = min(ans, temp) ans min(ans, temp) min ans temp print(ans) print ans temp = 0 0 temp ans = float('inf') float('inf') ans temp+=abs(c-totals[2]) abs(c-totals[2]) temp temp += 10 10 temp a, b, c = map(int, input().split()) map(int, input().split()) a l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l ans = min(ans, temp) min(ans, temp) ans temp+=abs(b-totals[1]) abs(b-totals[1]) temp c = map(int, input().split()) map(int, input().split()) c temp+=abs(a-totals[0]) abs(a-totals[0]) temp b, c = map(int, input().split()) map(int, input().split()) b totals = [0] * 3 [0] * 3 totals items = [0] * 3 [0] * 3 items n, a, b, c = map(int, input().split()) map(int, input().split()) n
from itertools import product
n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]

ans = float('inf')
for choice in product([0, 1, 2, 3], repeat=n):
    items = [0] * 3
    totals = [0] * 3
    temp = 0
    if min([choice.count(i) for i in range(3)]) == 0: continue
    for i, ch in enumerate(choice):
        if ch == 3: continue
        totals[ch] += l[i]
        items[ch] += 1
        if items[ch] > 1:
            temp += 10
    temp+=abs(a-totals[0])
    temp+=abs(b-totals[1])
    temp+=abs(c-totals[2])
    ans = min(ans, temp)
print(ans)