# Original solution
import math
N, A, B, C = 5, 100, 90, 80
ARR = [
    98,
    40,
    30,
    21,
    80
]

# N,A,B,C = 8, 100, 90, 80
# ARR = [
#     100,
#     100,
#     90,
#     90,
#     90,
#     80,
#     80,
#     80,
# ]


# N,A,B,C,= 8, 1000, 800, 100
# ARR = [
#     300,
#     333,
#     400,
#     444,
#     500,
#     555,
#     600,
#     666,
# ]

N,A,B,C = list(map(int,input().split()))
ARR = []
for i in range(N):
    ARR.append(int(eval(input())))

def calculate(n, arr, a, b, c):
    result = []
    for i in range(4 ** n):
        materialA = set()
        materialB = set()
        materialC = set()
        materialNone = set()
        for j in range(n):
            s = (i >> 2 * j & 1)
            t = (i >> (2 * j + 1) & 1)
            if (s == 0) and (t == 0):
                materialA.add(j)
            if (s == 1) and (t == 0):
                materialB.add(j)
            if (s == 0) and (t == 1):
                materialC.add(j)
            if (s == 1) and (t == 1):
                materialNone.add(j)

        ok, mp = judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone)
        if ok:
            result.append(mp)
    print((int(min(result))))

def judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone):


    if materialNone == n:
        return False, -1

    if len(materialA) == 0:
        return False, -1

    if len(materialB) == 0:
        return False, -1

    if len(materialC) == 0:
        return False, -1

    mpA = 0
    a = a - calculateResult(arr,materialA)
    mpA += math.fabs(a)
    if len(materialA) > 1:
        mpA += 10 * (len(materialA) - 1)

    mpB = 0
    b = b - calculateResult(arr,materialB)
    mpB += math.fabs(b)
    if len(materialB) > 1:
        mpB += 10 * (len(materialB) - 1)

    mpC = 0
    c = c - calculateResult(arr,materialC)
    mpC += math.fabs(c)
    if len(materialC) > 1:
        mpC += 10 * (len(materialC) - 1)


    return True,mpA+mpB+mpC

def calculateResult(arr,material):
    result = 0
    for m in material:
        result = result + arr[m]
    return result

calculate(N, ARR, A, B, C)


# Optimized solution
import math
# N, A, B, C = 7, 100, 90, 80
# ARR = [
#     98,
#     40,
#     30,
#     21,
#     80,
#     25,
#     100
# ]

N, A, B, C = list(map(int, input().split()))
ARR = []
for i in range(N):
    ARR.append(int(eval(input())))
result = []


def dfs(deep, crr):
    if deep == N:
        ok, res = calculate(crr)
        if ok:
            result.append(int(res))
    else:
        for i in range(4):
            crr[deep] = i
            dfs(deep + 1, crr)


def calculate(crr):
    sA = []
    sB = []
    sC = []
    sN = []
    for index, cr in enumerate(crr):
        if cr == 0:
            sN.append(ARR[index])
        if cr == 1:
            sA.append(ARR[index])
        if cr == 2:
            sB.append(ARR[index])
        if cr == 3:
            sC.append(ARR[index])

    if len(sA) == 0:
        return False, -1
    if len(sB) == 0:
        return False, -1
    if len(sC) == 0:
        return False, -1


    s1 = (len(sA) - 1) * 10 + math.fabs(sum(sA) - A)
    s2 = (len(sB) - 1) * 10 + math.fabs(sum(sB) - B)
    s3 = (len(sC) - 1) * 10 + math.fabs(sum(sC) - C)

    return True, s1 + s2 + s3


dfs(0, [0 for i in range(N)])

print((min(result)))