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

N, A, B, C = map(int, input().split())
ARR = []
for i in range(N):
    ARR.append(int(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)) import math math N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C ARR = [] ARR [] for i in range(N):
    ARR.append(int(input())) i range(N) range N ARR.append(int(input())) ARR.append ARR append int(input()) int input() input result = [] 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) dfs 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) deep == N deep N ok, res = calculate(crr) ok calculate(crr) calculate crr res if ok:
            result.append(int(res))
     ok result.append(int(res)) result.append result append int(res) int res for i in range(4):
            crr[deep] = i
            dfs(deep + 1, crr) i range(4) range 4 crr[deep] = i crr[deep] crr deep i dfs(deep + 1, crr) dfs deep + 1 deep 1 crr deep deep crr 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 calculate sA = [] sA [] sB = [] sB [] sC = [] sC [] sN = [] 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])

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

     cr == 3 cr 3 sC.append(ARR[index]) sC.append sC append ARR[index] ARR index if len(sA) == 0:
        return False, -1
     len(sA) == 0 len(sA) len sA 0 return False, -1 return False, -1 False -1 if len(sB) == 0:
        return False, -1
     len(sB) == 0 len(sB) len sB 0 return False, -1 return False, -1 False -1 if len(sC) == 0:
        return False, -1


     len(sC) == 0 len(sC) len sC 0 return False, -1 return False, -1 False -1 s1 = (len(sA) - 1) * 10 + math.fabs(sum(sA) - A) s1 (len(sA) - 1) * 10 + math.fabs(sum(sA) - A) (len(sA) - 1) * 10 len(sA) - 1 len(sA) len sA 1 10 math.fabs(sum(sA) - A) math.fabs math fabs sum(sA) - A sum(sA) sum sA A s2 = (len(sB) - 1) * 10 + math.fabs(sum(sB) - B) s2 (len(sB) - 1) * 10 + math.fabs(sum(sB) - B) (len(sB) - 1) * 10 len(sB) - 1 len(sB) len sB 1 10 math.fabs(sum(sB) - B) math.fabs math fabs sum(sB) - B sum(sB) sum sB B s3 = (len(sC) - 1) * 10 + math.fabs(sum(sC) - C) s3 (len(sC) - 1) * 10 + math.fabs(sum(sC) - C) (len(sC) - 1) * 10 len(sC) - 1 len(sC) len sC 1 10 math.fabs(sum(sC) - C) math.fabs math fabs sum(sC) - C sum(sC) sum sC C return True, s1 + s2 + s3 return True, s1 + s2 + s3 True s1 + s2 + s3 s1 + s2 s1 s2 s3 crr crr 0 for i in range(N) for i in range(N) i range(N) range N for i in range(N) 0 dfs(0, [0 for i in range(N)]) dfs 0 [0 for i in range(N)] print(min(result)) print min(result) min result A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C B, C = map(int, input().split()) map(int, input().split()) B ARR = [] [] ARR 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 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) dfs result = [] [] result N, A, B, C = map(int, input().split()) map(int, input().split()) N 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 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 calculate
import math
# N, A, B, C = 7, 100, 90, 80
# ARR = [
#     98,
#     40,
#     30,
#     21,
#     80,
#     25,
#     100
# ]

N, A, B, C = map(int, input().split())
ARR = []
for i in range(N):
    ARR.append(int(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))