import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

input=lambda :sys.stdin.readline().rstrip()

def resolve():

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

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



    def dfs(v,Idx)->int:

        # terminate condition

        if(v==n):

            score=0

            Idx=tuple(Idx)

            A,B,C=[],[],[]

            for i,k in enumerate(Idx):

                if(k==0): A.append(L[i])

                elif(k==1): B.append(L[i])

                elif(k==2): C.append(L[i])

            if((not A) or (not B) or (not C)): return INF # 1つも竹が無いのはダメ

            score+=(len(A)+len(B)+len(C)-3)*10



            SA=sum(A)

            SB=sum(B)

            SC=sum(C)

            score+=abs(SA-a)

            score+=abs(SB-b)

            score+=abs(SC-c)



            return score



        res=INF

        for i in range(4):

            res=min(res,dfs(v+1,Idx+[i]))

        return res



    print((dfs(0,[])))

resolve()
import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

input=lambda :sys.stdin.readline().rstrip()

def resolve():

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

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



    def dfs(v,Idx)->int:

        # terminate condition

        if(v==n):

            score=0

            Idx=tuple(Idx)

            A,B,C=[],[],[]

            for i,k in enumerate(Idx):

                if(k==0): A.append(L[i])

                elif(k==1): B.append(L[i])

                elif(k==2): C.append(L[i])

            if((not A) or (not B) or (not C)): return INF # 1つも竹が無いのはダメ

            score+=(len(A)+len(B)+len(C)-3)*10



            SA=sum(A)

            SB=sum(B)

            SC=sum(C)

            score+=abs(SA-a)

            score+=abs(SB-b)

            score+=abs(SC-c)

            return score

            

        res=INF

        for i in range(4):

            Idx[v]=i

            res=min(res,dfs(v+1,Idx))

        return res



    print((dfs(0,[0]*n)))

resolve()
import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    n, a, b, c = list(map(int, input().split()))
    L = [int(eval(input())) for _ in range(n)]

    def dfs(v, Idx) -> int:
        # terminate condition
        if v == n:
            score = 0
            Idx = tuple(Idx)
            A, B, C = [], [], []
            for i, k in enumerate(Idx):
                if k == 0:
                    A.append(L[i])
                elif k == 1:
                    B.append(L[i])
                elif k == 2:
                    C.append(L[i])
            if (not A) or (not B) or (not C):
                return INF  # 1つも竹が無いのはダメ
            score += (len(A) + len(B) + len(C) - 3) * 10
            SA = sum(A)
            SB = sum(B)
            SC = sum(C)
            score += abs(SA - a)
            score += abs(SB - b)
            score += abs(SC - c)
            return score
        res = INF
        for i in range(4):
            res = min(res, dfs(v + 1, Idx + [i]))
        return res

    print((dfs(0, [])))


resolve()

import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    n, a, b, c = list(map(int, input().split()))
    L = [int(eval(input())) for _ in range(n)]

    def dfs(v, Idx) -> int:
        # terminate condition
        if v == n:
            score = 0
            Idx = tuple(Idx)
            A, B, C = [], [], []
            for i, k in enumerate(Idx):
                if k == 0:
                    A.append(L[i])
                elif k == 1:
                    B.append(L[i])
                elif k == 2:
                    C.append(L[i])
            if (not A) or (not B) or (not C):
                return INF  # 1つも竹が無いのはダメ
            score += (len(A) + len(B) + len(C) - 3) * 10
            SA = sum(A)
            SB = sum(B)
            SC = sum(C)
            score += abs(SA - a)
            score += abs(SB - b)
            score += abs(SC - c)
            return score
        res = INF
        for i in range(4):
            Idx[v] = i
            res = min(res, dfs(v + 1, Idx))
        return res

    print((dfs(0, [0] * n)))


resolve()

-            res = min(res, dfs(v + 1, Idx + [i])) +            Idx[v] = i +            res = min(res, dfs(v + 1, Idx)) -    print((dfs(0, []))) +    print((dfs(0, [0] * n)))