def calc(T, bam):

    mix = len(bam) - 1

    total = sum(bam)

    return mix * 10 + abs(T - total)





N, A, B, C = list(map(int, input().split()))

L = [int(eval(input())) for _ in range(N)]





var = [[] for _ in range(N + 1)]

var[0].append('')



for i in range(N):

    for j in var[i]:

        for c in '0abc':

            var[i + 1].append(j + c)



V = var[N]



ans = 10 ** 6

for v in V:

    a = []

    b = []

    c = []

    cost = 0

    for i, m in enumerate(v):

        if m == 'a':

            a.append(L[i])

        elif m == 'b':

            b.append(L[i])

        elif m == 'c':

            c.append(L[i])

    if len(a) and len(b) and len(c):

        CA = calc(A, a)

        CB = calc(B, b)

        CC = calc(C, c)

        cost = CA + CB + CC

        if cost == 5:

            print('hello')

        ans = min(ans, cost)



print(ans)

import sys

sys.setrecursionlimit(10 ** 6)



N, A, B, C = list(map(int, input().split()))



L = [int(eval(input())) for _ in range(N)]

INF = 10 ** 12





def dfs(cur, a, b, c):

    if cur == N:

        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF

    ret0 = dfs(cur + 1, a, b, c)

    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10

    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10

    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10

    return min(ret0, ret1, ret2, ret3)





print((dfs(0, 0, 0, 0)))

def calc(T, bam):
    mix = len(bam) - 1
    total = sum(bam)
    return mix * 10 + abs(T - total)


N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
var = [[] for _ in range(N + 1)]
var[0].append("")
for i in range(N):
    for j in var[i]:
        for c in "0abc":
            var[i + 1].append(j + c)
V = var[N]
ans = 10**6
for v in V:
    a = []
    b = []
    c = []
    cost = 0
    for i, m in enumerate(v):
        if m == "a":
            a.append(L[i])
        elif m == "b":
            b.append(L[i])
        elif m == "c":
            c.append(L[i])
    if len(a) and len(b) and len(c):
        CA = calc(A, a)
        CB = calc(B, b)
        CC = calc(C, c)
        cost = CA + CB + CC
        if cost == 5:
            print("hello")
        ans = min(ans, cost)
print(ans)

import sys

sys.setrecursionlimit(10**6)
N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
INF = 10**12


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print((dfs(0, 0, 0, 0)))

-def calc(T, bam): -    mix = len(bam) - 1 -    total = sum(bam) -    return mix * 10 + abs(T - total) +import sys + +sys.setrecursionlimit(10**6) +N, A, B, C = list(map(int, input().split())) +L = [int(eval(input())) for _ in range(N)] +INF = 10**12 -N, A, B, C = list(map(int, input().split())) -L = [int(eval(input())) for _ in range(N)] -var = [[] for _ in range(N + 1)] -var[0].append("") -for i in range(N): -    for j in var[i]: -        for c in "0abc": -            var[i + 1].append(j + c) -V = var[N] -ans = 10**6 -for v in V: -    a = [] -    b = [] -    c = [] -    cost = 0 -    for i, m in enumerate(v): -        if m == "a": -            a.append(L[i]) -        elif m == "b": -            b.append(L[i]) -        elif m == "c": -            c.append(L[i]) -    if len(a) and len(b) and len(c): -        CA = calc(A, a) -        CB = calc(B, b) -        CC = calc(C, c) -        cost = CA + CB + CC -        if cost == 5: -            print("hello") -        ans = min(ans, cost) -print(ans) +def dfs(cur, a, b, c): +    if cur == N: +        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF +    ret0 = dfs(cur + 1, a, b, c) +    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10 +    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10 +    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10 +    return min(ret0, ret1, ret2, ret3) + + +print((dfs(0, 0, 0, 0)))