
n,a,b,c=map(int,input().split())
l=[0]*n
for i in range(n):
    l[i]=int(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)     n,a,b,c=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split a b c l=[0]*n l [0]*n [0] 0 n for i in range(n):
    l[i]=int(input())
     i range(n) range n l[i]=int(input()) l[i] l i int(input()) int input() input import itertools itertools mpmin=a+b+c+1 mpmin a+b+c+1 a+b+c a+b 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) i itertools.product([0,1,2,3], repeat=n) itertools.product itertools product [0,1,2,3] 0 1 2 3 repeat=n repeat n aa=0 aa 0 bb=0 bb 0 cc=0 cc 0 mpa=0 mpa 0 mpb=0 mpb 0 mpc=0 mpc 0 ia=0 ia 0 ib=0 ib 0 ic=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]
     ii range(n) 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]
     i[ii]==1 i[ii] i ii 1 ia=1 ia 1 if aa>0:
                mpa+=10
             aa>0 aa 0 mpa+=10 mpa 10 aa+=l[ii] aa l[ii] l ii elif i[ii]==2:
            ib=1
            if bb>0:
                mpb+=10
            bb+=l[ii]
         i[ii]==2 i[ii] i ii 2 ib=1 ib 1 if bb>0:
                mpb+=10
             bb>0 bb 0 mpb+=10 mpb 10 bb+=l[ii] bb l[ii] l ii elif i[ii]==3:
            ic=1
            if cc>0:
                mpc+=10
            cc+=l[ii]
     i[ii]==3 i[ii] i ii 3 ic=1 ic 1 if cc>0:
                mpc+=10
             cc>0 cc 0 mpc+=10 mpc 10 cc+=l[ii] cc l[ii] 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) ia==1 and ib==1 and ic==1 ia==1 and ib==1 ia==1 ia 1 ib==1 ib 1 ic==1 ic 1 mp=mpa+abs(a-aa)+mpb+abs(b-bb)+mpc+abs(c-cc) mp mpa+abs(a-aa)+mpb+abs(b-bb)+mpc+abs(c-cc) mpa+abs(a-aa)+mpb+abs(b-bb)+mpc mpa+abs(a-aa)+mpb+abs(b-bb) mpa+abs(a-aa)+mpb mpa+abs(a-aa) mpa abs(a-aa) abs a-aa a aa mpb abs(b-bb) abs b-bb b bb mpc abs(c-cc) abs c-cc c cc mpmin=min(mp,mpmin) mpmin min(mp,mpmin) min mp mpmin print(mpmin) print mpmin mpa+=10 10 mpa bb+=l[ii] l[ii] bb mpmin=min(mp,mpmin) min(mp,mpmin) mpmin aa+=l[ii] l[ii] aa a,b,c=map(int,input().split()) map(int,input().split()) a ib=1 1 ib aa=0 0 aa mpc=0 0 mpc mpc+=10 10 mpc mpb+=10 10 mpb bb=0 0 bb mpb=0 0 mpb mpmin=a+b+c+1 a+b+c+1 mpmin ic=0 0 ic b,c=map(int,input().split()) map(int,input().split()) b ia=0 0 ia ib=0 0 ib mpa=0 0 mpa ic=1 1 ic c=map(int,input().split()) map(int,input().split()) c l=[0]*n [0]*n l mp=mpa+abs(a-aa)+mpb+abs(b-bb)+mpc+abs(c-cc) mpa+abs(a-aa)+mpb+abs(b-bb)+mpc+abs(c-cc) mp n,a,b,c=map(int,input().split()) map(int,input().split()) n cc+=l[ii] l[ii] cc cc=0 0 cc ia=1 1 ia

n,a,b,c=map(int,input().split())
l=[0]*n
for i in range(n):
    l[i]=int(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)    
