from itertools import product

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

ans = 10 ** 10
for bit in product([0, 1, 2, 3], repeat=n):
    tmp = [0] * 4
    mp = 0
    for i, j in enumerate(bit):
        if j != 3 and tmp[j] != 0:
            mp += 10
        tmp[j] += l[i]
    if any([i == 0 for i in tmp[:3]]):
        continue
    mp += abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2])
    ans = min(ans, mp)
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 _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] ans = 10 ** 10 ans 10 ** 10 10 10 for bit in product([0, 1, 2, 3], repeat=n):
    tmp = [0] * 4
    mp = 0
    for i, j in enumerate(bit):
        if j != 3 and tmp[j] != 0:
            mp += 10
        tmp[j] += l[i]
    if any([i == 0 for i in tmp[:3]]):
        continue
    mp += abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2])
    ans = min(ans, mp) bit product([0, 1, 2, 3], repeat=n) product [0, 1, 2, 3] 0 1 2 3 repeat=n repeat n tmp = [0] * 4 tmp [0] * 4 [0] 0 4 mp = 0 mp 0 for i, j in enumerate(bit):
        if j != 3 and tmp[j] != 0:
            mp += 10
        tmp[j] += l[i]
     i j enumerate(bit) enumerate bit if j != 3 and tmp[j] != 0:
            mp += 10
         j != 3 and tmp[j] != 0 j != 3 j 3 tmp[j] != 0 tmp[j] tmp j 0 mp += 10 mp 10 tmp[j] += l[i] tmp[j] tmp j l[i] l i if any([i == 0 for i in tmp[:3]]):
        continue
     any([i == 0 for i in tmp[:3]]) any [i == 0 for i in tmp[:3]] continue mp += abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2]) mp abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2]) abs(a - tmp[0]) + abs(b - tmp[1]) abs(a - tmp[0]) abs a - tmp[0] a tmp[0] tmp 0 abs(b - tmp[1]) abs b - tmp[1] b tmp[1] tmp 1 abs(c - tmp[2]) abs c - tmp[2] c tmp[2] tmp 2 ans = min(ans, mp) ans min(ans, mp) min ans mp print(ans) print ans n, a, b, c = map(int, input().split()) map(int, input().split()) n c = map(int, input().split()) map(int, input().split()) c ans = min(ans, mp) min(ans, mp) ans l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l tmp = [0] * 4 [0] * 4 tmp mp = 0 0 mp b, c = map(int, input().split()) map(int, input().split()) b a, b, c = map(int, input().split()) map(int, input().split()) a ans = 10 ** 10 10 ** 10 ans mp += 10 10 mp mp += abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2]) abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2]) mp
from itertools import product

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

ans = 10 ** 10
for bit in product([0, 1, 2, 3], repeat=n):
    tmp = [0] * 4
    mp = 0
    for i, j in enumerate(bit):
        if j != 3 and tmp[j] != 0:
            mp += 10
        tmp[j] += l[i]
    if any([i == 0 for i in tmp[:3]]):
        continue
    mp += abs(a - tmp[0]) + abs(b - tmp[1]) + abs(c - tmp[2])
    ans = min(ans, mp)
print(ans)
