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

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

answer = a+b+c

def Base_10_to_n(X, n):

    if (int(X/n)):

        return Base_10_to_n(int(X/n), n)+str(X%n)

    return str(X%n)

  

for i in range(1, 4**n):

  aa = []

  bb = []

  cc = []

  four = list(str(Base_10_to_n(i,4).zfill(n)))

  

  if four.count("1")==0 or four.count("2")==0 or four.count("3") ==0:

    continue

  for index,f in enumerate(four) :

    if f == "0": #使わない

      continue

    elif f == "1":

      aa.append(l[index])

    elif f == "2":

      bb.append(l[index])

    elif f == "3":

      cc.append(l[index])

    else:

      break

  cur = (len(aa)-1)*10+abs(a-sum(aa))+(len(bb)-1)*10+abs(b-sum(bb))+(len(cc)-1)*10+abs(c-sum(cc))

  answer = min(answer, cur)





  

print(answer)

    

  
#!/usr/bin/env python3

import sys

import itertools



def solve(N: int, A: int, B: int, C: int, l: "List[int]"):

    # 0: 使わない 1:A 2:B 3:C

    all = list(itertools.product([0,1,2,3], repeat=N))

    answer = 10**9

    for a in all:

        a_sum = 0

        a_count = 0

        b_sum = 0

        b_count = 0

        c_sum = 0

        c_count = 0



        for i in range(len(a)):

            if a[i] == 0:

                continue

            elif a[i] == 1:

                a_sum += l[i]

                a_count +=1

            elif a[i] == 2:

                b_sum += l[i]

                b_count +=1

            elif a[i] == 3:

                c_sum += l[i]

                c_count +=1

        

        if a_count == 0 or b_count == 0 or c_count==0 :

            continue



        MP = (a_count-1)*10+(b_count-1)*10+(c_count-1)*10+abs(A-a_sum)+abs(B-b_sum)+abs(C-c_sum)



        answer = min(MP,answer)

    print(answer)

    return





def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    A = int(next(tokens))  # type: int

    B = int(next(tokens))  # type: int

    C = int(next(tokens))  # type: int

    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"

    solve(N, A, B, C, l)



if __name__ == '__main__':

    main()

n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
answer = a + b + c


def Base_10_to_n(X, n):
    if int(X / n):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)


for i in range(1, 4**n):
    aa = []
    bb = []
    cc = []
    four = list(str(Base_10_to_n(i, 4).zfill(n)))
    if four.count("1") == 0 or four.count("2") == 0 or four.count("3") == 0:
        continue
    for index, f in enumerate(four):
        if f == "0":  # 使わない
            continue
        elif f == "1":
            aa.append(l[index])
        elif f == "2":
            bb.append(l[index])
        elif f == "3":
            cc.append(l[index])
        else:
            break
    cur = (
        (len(aa) - 1) * 10
        + abs(a - sum(aa))
        + (len(bb) - 1) * 10
        + abs(b - sum(bb))
        + (len(cc) - 1) * 10
        + abs(c - sum(cc))
    )
    answer = min(answer, cur)
print(answer)

#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    # 0: 使わない 1:A 2:B 3:C
    all = list(itertools.product([0, 1, 2, 3], repeat=N))
    answer = 10**9
    for a in all:
        a_sum = 0
        a_count = 0
        b_sum = 0
        b_count = 0
        c_sum = 0
        c_count = 0
        for i in range(len(a)):
            if a[i] == 0:
                continue
            elif a[i] == 1:
                a_sum += l[i]
                a_count += 1
            elif a[i] == 2:
                b_sum += l[i]
                b_count += 1
            elif a[i] == 3:
                c_sum += l[i]
                c_count += 1
        if a_count == 0 or b_count == 0 or c_count == 0:
            continue
        MP = (
            (a_count - 1) * 10
            + (b_count - 1) * 10
            + (c_count - 1) * 10
            + abs(A - a_sum)
            + abs(B - b_sum)
            + abs(C - c_sum)
        )
        answer = min(MP, answer)
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C, l)


if __name__ == "__main__":
    main()

-n, a, b, c = list(map(int, input().split())) -l = [int(eval(input())) for _ in range(n)] -answer = a + b + c +#!/usr/bin/env python3 +import sys +import itertools -def Base_10_to_n(X, n): -    if int(X / n): -        return Base_10_to_n(int(X / n), n) + str(X % n) -    return str(X % n) +def solve(N: int, A: int, B: int, C: int, l: "List[int]"): +    # 0: 使わない 1:A 2:B 3:C +    all = list(itertools.product([0, 1, 2, 3], repeat=N)) +    answer = 10**9 +    for a in all: +        a_sum = 0 +        a_count = 0 +        b_sum = 0 +        b_count = 0 +        c_sum = 0 +        c_count = 0 +        for i in range(len(a)): +            if a[i] == 0: +                continue +            elif a[i] == 1: +                a_sum += l[i] +                a_count += 1 +            elif a[i] == 2: +                b_sum += l[i] +                b_count += 1 +            elif a[i] == 3: +                c_sum += l[i] +                c_count += 1 +        if a_count == 0 or b_count == 0 or c_count == 0: +            continue +        MP = ( +            (a_count - 1) * 10 +            + (b_count - 1) * 10 +            + (c_count - 1) * 10 +            + abs(A - a_sum) +            + abs(B - b_sum) +            + abs(C - c_sum) +        ) +        answer = min(MP, answer) +    print(answer) +    return -for i in range(1, 4**n): -    aa = [] -    bb = [] -    cc = [] -    four = list(str(Base_10_to_n(i, 4).zfill(n))) -    if four.count("1") == 0 or four.count("2") == 0 or four.count("3") == 0: -        continue -    for index, f in enumerate(four): -        if f == "0":  # 使わない -            continue -        elif f == "1": -            aa.append(l[index]) -        elif f == "2": -            bb.append(l[index]) -        elif f == "3": -            cc.append(l[index]) -        else: -            break -    cur = ( -        (len(aa) - 1) * 10 -        + abs(a - sum(aa)) -        + (len(bb) - 1) * 10 -        + abs(b - sum(bb)) -        + (len(cc) - 1) * 10 -        + abs(c - sum(cc)) -    ) -    answer = min(answer, cur) -print(answer) +def main(): +    def iterate_tokens(): +        for line in sys.stdin: +            for word in line.split(): +                yield word + +    tokens = iterate_tokens() +    N = int(next(tokens))  # type: int +    A = int(next(tokens))  # type: int +    B = int(next(tokens))  # type: int +    C = int(next(tokens))  # type: int +    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]" +    solve(N, A, B, C, l) + + +if __name__ == "__main__": +    main()