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

from itertools import product
ptns = list(product([0,1,2,-1], repeat = n))

ans = 10**9
for i in range(len(ptns)):
    if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
    abc = [0, 0, 0, -30]
    for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
    mp = abc[3]
    mp += abs(abc[0] - a)
    mp += abs(abc[1] - b)
    mp += abs(abc[2] - c)
    ans = min(ans, mp)

print(ans) 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)] from itertools import product ptns = list(product([0,1,2,-1], repeat = n)) ptns list(product([0,1,2,-1], repeat = n)) list product([0,1,2,-1], repeat = n) product [0,1,2,-1] 0 1 2 -1 repeat = n repeat n ans = 10**9 ans 10**9 10 9 for i in range(len(ptns)):
    if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
    abc = [0, 0, 0, -30]
    for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
    mp = abc[3]
    mp += abs(abc[0] - a)
    mp += abs(abc[1] - b)
    mp += abs(abc[2] - c)
    ans = min(ans, mp) i range(len(ptns)) range len(ptns) len ptns if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
     0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i] 0 not in ptns[i] or 1 not in ptns[i] 0 not in ptns[i] 0 ptns[i] ptns i 1 not in ptns[i] 1 ptns[i] ptns i 2 not in ptns[i] 2 ptns[i] ptns i continue abc = [0, 0, 0, -30] abc [0, 0, 0, -30] 0 0 0 -30 for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
     j range(n) range n tmp = ptns[i][j] tmp ptns[i][j] [i] ptns i j if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
     tmp >= 0 tmp 0 abc[tmp] += l[j] abc[tmp] abc tmp l[j] l j abc[3] += 10 abc[3] abc 3 10 mp = abc[3] mp abc[3] abc 3 mp += abs(abc[0] - a) mp abs(abc[0] - a) abs abc[0] - a abc[0] abc 0 a mp += abs(abc[1] - b) mp abs(abc[1] - b) abs abc[1] - b abc[1] abc 1 b mp += abs(abc[2] - c) mp abs(abc[2] - c) abs abc[2] - c abc[2] abc 2 c ans = min(ans, mp) ans min(ans, mp) min ans mp print(ans) print ans ans = 10**9 10**9 ans l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l a, b, c = map(int, input().split()) map(int, input().split()) a mp += abs(abc[0] - a) abs(abc[0] - a) mp tmp = ptns[i][j] ptns[i][j] tmp n, a, b, c = map(int, input().split()) map(int, input().split()) n mp = abc[3] abc[3] mp mp += abs(abc[1] - b) abs(abc[1] - b) mp mp += abs(abc[2] - c) abs(abc[2] - c) mp ans = min(ans, mp) min(ans, mp) ans abc = [0, 0, 0, -30] [0, 0, 0, -30] abc c = map(int, input().split()) map(int, input().split()) c ptns = list(product([0,1,2,-1], repeat = n)) list(product([0,1,2,-1], repeat = n)) ptns b, c = map(int, input().split()) map(int, input().split()) b
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

from itertools import product
ptns = list(product([0,1,2,-1], repeat = n))

ans = 10**9
for i in range(len(ptns)):
    if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
    abc = [0, 0, 0, -30]
    for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
    mp = abc[3]
    mp += abs(abc[0] - a)
    mp += abs(abc[1] - b)
    mp += abs(abc[2] - c)
    ans = min(ans, mp)

print(ans)