# ＤＦＳ, パターン列挙_各竹の使用パターンを列挙



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

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



stack = [[0],[1],[2],[-1]] # 初期化_ここでは竹の使用パターン4つを設置

ptns = [] # パターン候補の器_初期化

 

while stack: # stackが空になるまでループ

    tmp = stack.pop() # パターンの候補を pop

    if len(tmp) == n: # 条件に合えば append

        ptns.append(tmp)

    elif len(tmp) < n: # 条件に合わなければ...

        w = tmp + [0] # パターンの候補を作成して...

        x = tmp + [1] # 〃

        y = tmp + [2] # 〃

        z = tmp + [-1]

        stack += [w, x, y, z]  # 積む



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 = list(map(int, input().split()))

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



stack = [[0],[1],[2],[-1]]



ans = 10**9

while stack:

    tmp = stack.pop()

    if len(tmp) == n:

        if 0 not in tmp or 1 not in tmp or 2 not in tmp:

            continue

        abc = [0, 0, 0, -30]

        for j in range(n):

            if tmp[j] >= 0:

                abc[tmp[j]] += 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)



    elif len(tmp) < n:

        w = tmp + [0]

        x = tmp + [1]

        y = tmp + [2]

        z = tmp + [-1]

        stack += [w, x, y, z]



print(ans)

# ＤＦＳ, パターン列挙_各竹の使用パターンを列挙
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
stack = [[0], [1], [2], [-1]]  # 初期化_ここでは竹の使用パターン4つを設置
ptns = []  # パターン候補の器_初期化
while stack:  # stackが空になるまでループ
    tmp = stack.pop()  # パターンの候補を pop
    if len(tmp) == n:  # 条件に合えば append
        ptns.append(tmp)
    elif len(tmp) < n:  # 条件に合わなければ...
        w = tmp + [0]  # パターンの候補を作成して...
        x = tmp + [1]  # 〃
        y = tmp + [2]  # 〃
        z = tmp + [-1]
        stack += [w, x, y, z]  # 積む
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 = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
stack = [[0], [1], [2], [-1]]
ans = 10**9
while stack:
    tmp = stack.pop()
    if len(tmp) == n:
        if 0 not in tmp or 1 not in tmp or 2 not in tmp:
            continue
        abc = [0, 0, 0, -30]
        for j in range(n):
            if tmp[j] >= 0:
                abc[tmp[j]] += 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)
    elif len(tmp) < n:
        w = tmp + [0]
        x = tmp + [1]
        y = tmp + [2]
        z = tmp + [-1]
        stack += [w, x, y, z]
print(ans)

-stack = [[0], [1], [2], [-1]]  # 初期化_ここでは竹の使用パターン4つを設置 -ptns = []  # パターン候補の器_初期化 -while stack:  # stackが空になるまでループ -    tmp = stack.pop()  # パターンの候補を pop -    if len(tmp) == n:  # 条件に合えば append -        ptns.append(tmp) -    elif len(tmp) < n:  # 条件に合わなければ... -        w = tmp + [0]  # パターンの候補を作成して... -        x = tmp + [1]  # 〃 -        y = tmp + [2]  # 〃 +stack = [[0], [1], [2], [-1]] +ans = 10**9 +while stack: +    tmp = stack.pop() +    if len(tmp) == n: +        if 0 not in tmp or 1 not in tmp or 2 not in tmp: +            continue +        abc = [0, 0, 0, -30] +        for j in range(n): +            if tmp[j] >= 0: +                abc[tmp[j]] += 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) +    elif len(tmp) < n: +        w = tmp + [0] +        x = tmp + [1] +        y = tmp + [2] -        stack += [w, x, y, z]  # 積む -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) +        stack += [w, x, y, z]