l=[]

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

for i in range(n):

    li=int(eval(input()))

    l.append(li)



d=[a,b,c]

d.sort()



mpmin=sum(l)*4+len(l)*10+sum(d)

for i in range(4**n):

    k=[]

    kj=i%4

    k.append(kj)

    b=int((i-kj)/4)

    l0=[]

    l1=[]

    l2=[]

    l3=[]

    if kj==0:

        l0.append(l[0])

    elif kj==1:

        l1.append(l[0])

    elif kj==2:

        l2.append(l[0])

    elif kj==3:

        l3.append(l[0])

        

    for j in range(n-1):

        kj=b%4

        k.append(kj)

        b=int((b-kj)/4)

        if kj==0:

            l0.append(l[j+1])

        elif kj==1:

            l1.append(l[j+1])

        elif kj==2:

            l2.append(l[j+1])

        elif kj==3:

            l3.append(l[j+1])

    mp=0

    if len(l0)>=1:

        mp=mp+(len(l0)-1)*10

    if len(l1)>=1:

        mp=mp+(len(l1)-1)*10

    if len(l2)>=1:

        mp=mp+(len(l2)-1)*10

    ls=[]

    ls=[sum(l0),sum(l1),sum(l2)]

    ls.sort()

    mp=mp+abs(d[0]-ls[0])+abs(d[1]-ls[1])+abs(d[2]-ls[2])    

    if mpmin>mp and len(l0)>=1 and len(l1)>=1 and len(l2)>=1:

        mpmin=mp

print(mpmin)        

        



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

l=[0]*n

for i in range(n):

    l[i]=int(eval(input()))

    

import itertools

 

mpmin=a+b+c+1

for i in itertools.product([0,1,2,3], repeat=n):

    aa=0

    bb=0

    cc=0

    mpa=0

    mpb=0

    mpc=0

    ia=0

    ib=0

    ic=0

    for ii in range(n):

        if i[ii]==1:

            ia=1

            if aa>0:

                mpa+=10

            aa+=l[ii]

        elif i[ii]==2:

            ib=1

            if bb>0:

                mpb+=10

            bb+=l[ii]

        elif i[ii]==3:

            ic=1

            if cc>0:

                mpc+=10

            cc+=l[ii]

    if ia==1 and ib==1 and ic==1:

        mp=mpa+abs(a-aa)+mpb+abs(b-bb)+mpc+abs(c-cc)

#        if mp<mpmin:

#            print(mp,mpa,mpb,mpc,i)

        mpmin=min(mp,mpmin)



print(mpmin)    

l = []
n, a, b, c = list(map(int, input().split()))
for i in range(n):
    li = int(eval(input()))
    l.append(li)
d = [a, b, c]
d.sort()
mpmin = sum(l) * 4 + len(l) * 10 + sum(d)
for i in range(4**n):
    k = []
    kj = i % 4
    k.append(kj)
    b = int((i - kj) / 4)
    l0 = []
    l1 = []
    l2 = []
    l3 = []
    if kj == 0:
        l0.append(l[0])
    elif kj == 1:
        l1.append(l[0])
    elif kj == 2:
        l2.append(l[0])
    elif kj == 3:
        l3.append(l[0])
    for j in range(n - 1):
        kj = b % 4
        k.append(kj)
        b = int((b - kj) / 4)
        if kj == 0:
            l0.append(l[j + 1])
        elif kj == 1:
            l1.append(l[j + 1])
        elif kj == 2:
            l2.append(l[j + 1])
        elif kj == 3:
            l3.append(l[j + 1])
    mp = 0
    if len(l0) >= 1:
        mp = mp + (len(l0) - 1) * 10
    if len(l1) >= 1:
        mp = mp + (len(l1) - 1) * 10
    if len(l2) >= 1:
        mp = mp + (len(l2) - 1) * 10
    ls = []
    ls = [sum(l0), sum(l1), sum(l2)]
    ls.sort()
    mp = mp + abs(d[0] - ls[0]) + abs(d[1] - ls[1]) + abs(d[2] - ls[2])
    if mpmin > mp and len(l0) >= 1 and len(l1) >= 1 and len(l2) >= 1:
        mpmin = mp
print(mpmin)

n, a, b, c = list(map(int, input().split()))
l = [0] * n
for i in range(n):
    l[i] = int(eval(input()))
import itertools

mpmin = a + b + c + 1
for i in itertools.product([0, 1, 2, 3], repeat=n):
    aa = 0
    bb = 0
    cc = 0
    mpa = 0
    mpb = 0
    mpc = 0
    ia = 0
    ib = 0
    ic = 0
    for ii in range(n):
        if i[ii] == 1:
            ia = 1
            if aa > 0:
                mpa += 10
            aa += l[ii]
        elif i[ii] == 2:
            ib = 1
            if bb > 0:
                mpb += 10
            bb += l[ii]
        elif i[ii] == 3:
            ic = 1
            if cc > 0:
                mpc += 10
            cc += l[ii]
    if ia == 1 and ib == 1 and ic == 1:
        mp = mpa + abs(a - aa) + mpb + abs(b - bb) + mpc + abs(c - cc)
        #        if mp<mpmin:
        #            print(mp,mpa,mpb,mpc,i)
        mpmin = min(mp, mpmin)
print(mpmin)

-l = [] +l = [0] * n -    li = int(eval(input())) -    l.append(li) -d = [a, b, c] -d.sort() -mpmin = sum(l) * 4 + len(l) * 10 + sum(d) -for i in range(4**n): -    k = [] -    kj = i % 4 -    k.append(kj) -    b = int((i - kj) / 4) -    l0 = [] -    l1 = [] -    l2 = [] -    l3 = [] -    if kj == 0: -        l0.append(l[0]) -    elif kj == 1: -        l1.append(l[0]) -    elif kj == 2: -        l2.append(l[0]) -    elif kj == 3: -        l3.append(l[0]) -    for j in range(n - 1): -        kj = b % 4 -        k.append(kj) -        b = int((b - kj) / 4) -        if kj == 0: -            l0.append(l[j + 1]) -        elif kj == 1: -            l1.append(l[j + 1]) -        elif kj == 2: -            l2.append(l[j + 1]) -        elif kj == 3: -            l3.append(l[j + 1]) -    mp = 0 -    if len(l0) >= 1: -        mp = mp + (len(l0) - 1) * 10 -    if len(l1) >= 1: -        mp = mp + (len(l1) - 1) * 10 -    if len(l2) >= 1: -        mp = mp + (len(l2) - 1) * 10 -    ls = [] -    ls = [sum(l0), sum(l1), sum(l2)] -    ls.sort() -    mp = mp + abs(d[0] - ls[0]) + abs(d[1] - ls[1]) + abs(d[2] - ls[2]) -    if mpmin > mp and len(l0) >= 1 and len(l1) >= 1 and len(l2) >= 1: -        mpmin = mp +    l[i] = int(eval(input())) +import itertools + +mpmin = a + b + c + 1 +for i in itertools.product([0, 1, 2, 3], repeat=n): +    aa = 0 +    bb = 0 +    cc = 0 +    mpa = 0 +    mpb = 0 +    mpc = 0 +    ia = 0 +    ib = 0 +    ic = 0 +    for ii in range(n): +        if i[ii] == 1: +            ia = 1 +            if aa > 0: +                mpa += 10 +            aa += l[ii] +        elif i[ii] == 2: +            ib = 1 +            if bb > 0: +                mpb += 10 +            bb += l[ii] +        elif i[ii] == 3: +            ic = 1 +            if cc > 0: +                mpc += 10 +            cc += l[ii] +    if ia == 1 and ib == 1 and ic == 1: +        mp = mpa + abs(a - aa) + mpb + abs(b - bb) + mpc + abs(c - cc) +        #        if mp<mpmin: +        #            print(mp,mpa,mpb,mpc,i) +        mpmin = min(mp, mpmin)