def main():

    #入力をとる

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

    moto = [int(eval(input())) for i in range(n)]



    take = []

    take.append(a)

    take.append(b)

    take.append(c)



    mp = 10000000000

    pt= []

    #全探索

    for i in range(2**(2*n)):

        pt = []

        for j in range(n):

            if (i >> j*2)&1:

                if (i >> j*2+1)&1:

                    pt.append(3)

                else:

                    pt.append(1)

            else:

                if (i >> j*2+1)&1:

                    pt.append(2)

                else:

                    pt.append(0)       



        #keisan

        mp_tmp = 0

        all_used = True

        for k in range(3):

            if pt.count(k) == 0:

                all_used = False

                break



            sum_tmp = 0

            mp_tmp += (pt.count(k) - 1)*10

            for l in range(n):

                if pt[l] == k:

                    sum_tmp += moto[l]

            

            mp_tmp += abs(sum_tmp-take[k])



        if all_used == True:

            mp = min(mp_tmp, mp)

    print(mp)



main()
minmp = 10000000

def dfs(depth, pt):



    if depth==n:

        mp_tmp = 0

        all_used = True

        for k in range(3):

            if pt.count(k) == 0:

                all_used = False

                break



            sum_tmp = 0

            mp_tmp += (pt.count(k) - 1)*10

            for l in range(n):

                if pt[l] == k:

                    sum_tmp += moto[l]

            

            mp_tmp += abs(sum_tmp-take[k])



        if all_used == True:

            global minmp

            minmp = min(minmp,mp_tmp)

            return

        else:

            return



    for i in range(4):

        pt[depth] = i

        dfs(depth+1, pt)



    return



#入力をとる

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

moto = [int(eval(input())) for i in range(n)]





take = []

take.append(a)

take.append(b)

take.append(c)



pt  = [3]*n

for i in range(n):

    dfs(i,pt)



print(minmp)
def main():
    # 入力をとる
    n, a, b, c = list(map(int, input().split()))
    moto = [int(eval(input())) for i in range(n)]
    take = []
    take.append(a)
    take.append(b)
    take.append(c)
    mp = 10000000000
    pt = []
    # 全探索
    for i in range(2 ** (2 * n)):
        pt = []
        for j in range(n):
            if (i >> j * 2) & 1:
                if (i >> j * 2 + 1) & 1:
                    pt.append(3)
                else:
                    pt.append(1)
            else:
                if (i >> j * 2 + 1) & 1:
                    pt.append(2)
                else:
                    pt.append(0)
        # keisan
        mp_tmp = 0
        all_used = True
        for k in range(3):
            if pt.count(k) == 0:
                all_used = False
                break
            sum_tmp = 0
            mp_tmp += (pt.count(k) - 1) * 10
            for l in range(n):
                if pt[l] == k:
                    sum_tmp += moto[l]
            mp_tmp += abs(sum_tmp - take[k])
        if all_used == True:
            mp = min(mp_tmp, mp)
    print(mp)


main()

minmp = 10000000


def dfs(depth, pt):
    if depth == n:
        mp_tmp = 0
        all_used = True
        for k in range(3):
            if pt.count(k) == 0:
                all_used = False
                break
            sum_tmp = 0
            mp_tmp += (pt.count(k) - 1) * 10
            for l in range(n):
                if pt[l] == k:
                    sum_tmp += moto[l]
            mp_tmp += abs(sum_tmp - take[k])
        if all_used == True:
            global minmp
            minmp = min(minmp, mp_tmp)
            return
        else:
            return
    for i in range(4):
        pt[depth] = i
        dfs(depth + 1, pt)
    return


# 入力をとる
n, a, b, c = list(map(int, input().split()))
moto = [int(eval(input())) for i in range(n)]
take = []
take.append(a)
take.append(b)
take.append(c)
pt = [3] * n
for i in range(n):
    dfs(i, pt)
print(minmp)

-def main(): -    # 入力をとる -    n, a, b, c = list(map(int, input().split())) -    moto = [int(eval(input())) for i in range(n)] -    take = [] -    take.append(a) -    take.append(b) -    take.append(c) -    mp = 10000000000 -    pt = [] -    # 全探索 -    for i in range(2 ** (2 * n)): -        pt = [] -        for j in range(n): -            if (i >> j * 2) & 1: -                if (i >> j * 2 + 1) & 1: -                    pt.append(3) -                else: -                    pt.append(1) -            else: -                if (i >> j * 2 + 1) & 1: -                    pt.append(2) -                else: -                    pt.append(0) -        # keisan +minmp = 10000000 + + +def dfs(depth, pt): +    if depth == n: -            mp = min(mp_tmp, mp) -    print(mp) +            global minmp +            minmp = min(minmp, mp_tmp) +            return +        else: +            return +    for i in range(4): +        pt[depth] = i +        dfs(depth + 1, pt) +    return -main() +# 入力をとる +n, a, b, c = list(map(int, input().split())) +moto = [int(eval(input())) for i in range(n)] +take = [] +take.append(a) +take.append(b) +take.append(c) +pt = [3] * n +for i in range(n): +    dfs(i, pt) +print(minmp)