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 = map(int,input().split())
ARR = []
for i in range(N):
    ARR.append(int(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 & materialB) > 0:
        return False, -1

    if len(materialA & materialC) > 0:
        return False, -1

    if len(materialB & materialC) > 0:
        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) import math math N, A, B, C = 5, 100, 90, 80 N 5 A 100 B 90 C 80 ARR = [
    98,
    40,
    30,
    21,
    80
] ARR [
    98,
    40,
    30,
    21,
    80
] 98 40 30 21 80 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 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))) calculate result = [] 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)
     i range(4 ** n) range 4 ** n 4 n materialA = set() materialA set() set materialB = set() materialB set() set materialC = set() materialC set() set materialNone = set() materialNone set() 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)

         j range(n) range n s = (i >> 2 * j & 1) s i >> 2 * j & 1 i >> 2 * j i 2 * j 2 j 1 t = (i >> (2 * j + 1) & 1) t i >> (2 * j + 1) & 1 i >> (2 * j + 1) i 2 * j + 1 2 * j 2 j 1 1 if (s == 0) and (t == 0):
                materialA.add(j)
             (s == 0) and (t == 0) s == 0 s 0 t == 0 t 0 materialA.add(j) materialA.add materialA add j if (s == 1) and (t == 0):
                materialB.add(j)
             (s == 1) and (t == 0) s == 1 s 1 t == 0 t 0 materialB.add(j) materialB.add materialB add j if (s == 0) and (t == 1):
                materialC.add(j)
             (s == 0) and (t == 1) s == 0 s 0 t == 1 t 1 materialC.add(j) materialC.add materialC add j if (s == 1) and (t == 1):
                materialNone.add(j)

         (s == 1) and (t == 1) s == 1 s 1 t == 1 t 1 materialNone.add(j) materialNone.add materialNone add j ok, mp = judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone) ok judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone) judge n arr a b c materialA materialB materialC materialNone mp if ok:
            result.append(mp)
     ok result.append(mp) result.append result append mp print(int(min(result))) print int(min(result)) int min(result) min result n n arr arr a a b b c c def judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone):


    if materialNone == n:
        return False, -1

    if len(materialA & materialB) > 0:
        return False, -1

    if len(materialA & materialC) > 0:
        return False, -1

    if len(materialB & materialC) > 0:
        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 judge if materialNone == n:
        return False, -1

     materialNone == n materialNone n return False, -1 return False, -1 False -1 if len(materialA & materialB) > 0:
        return False, -1

     len(materialA & materialB) > 0 len(materialA & materialB) len materialA & materialB materialA materialB 0 return False, -1 return False, -1 False -1 if len(materialA & materialC) > 0:
        return False, -1

     len(materialA & materialC) > 0 len(materialA & materialC) len materialA & materialC materialA materialC 0 return False, -1 return False, -1 False -1 if len(materialB & materialC) > 0:
        return False, -1

     len(materialB & materialC) > 0 len(materialB & materialC) len materialB & materialC materialB materialC 0 return False, -1 return False, -1 False -1 if len(materialA) == 0:
        return False, -1

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

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

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

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

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


     len(materialC) > 1 len(materialC) len materialC 1 mpC += 10 * (len(materialC) - 1) mpC 10 * (len(materialC) - 1) 10 len(materialC) - 1 len(materialC) len materialC 1 return True,mpA+mpB+mpC return True,mpA+mpB+mpC True mpA+mpB+mpC mpA+mpB mpA mpB mpC n n arr arr a a b b c c materialA materialA materialB materialB materialC materialC materialNone materialNone def calculateResult(arr,material):
    result = 0
    for m in material:
        result = result + arr[m]
    return result calculateResult result = 0 result 0 for m in material:
        result = result + arr[m]
     m material result = result + arr[m] result result + arr[m] result arr[m] arr m return result result arr arr material material calculate(N, ARR, A, B, C) calculate N ARR A B C C = 5, 100, 90, 80 80 C def judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone):


    if materialNone == n:
        return False, -1

    if len(materialA & materialB) > 0:
        return False, -1

    if len(materialA & materialC) > 0:
        return False, -1

    if len(materialB & materialC) > 0:
        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 judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone):


    if materialNone == n:
        return False, -1

    if len(materialA & materialB) > 0:
        return False, -1

    if len(materialA & materialC) > 0:
        return False, -1

    if len(materialB & materialC) > 0:
        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 judge B, C = 5, 100, 90, 80 90 B A,B,C = map(int,input().split()) map(int,input().split()) A N, A, B, C = 5, 100, 90, 80 5 N B,C = map(int,input().split()) map(int,input().split()) B C = map(int,input().split()) map(int,input().split()) C A, B, C = 5, 100, 90, 80 100 A ARR = [
    98,
    40,
    30,
    21,
    80
] [
    98,
    40,
    30,
    21,
    80
] ARR def calculateResult(arr,material):
    result = 0
    for m in material:
        result = result + arr[m]
    return result def calculateResult(arr,material):
    result = 0
    for m in material:
        result = result + arr[m]
    return result calculateResult N,A,B,C = map(int,input().split()) map(int,input().split()) N ARR = [] [] ARR 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 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))) calculate
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 = map(int,input().split())
ARR = []
for i in range(N):
    ARR.append(int(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 & materialB) > 0:
        return False, -1

    if len(materialA & materialC) > 0:
        return False, -1

    if len(materialB & materialC) > 0:
        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)
