#全探索をA,B,C一度で分けた
# RE 1   ac 19

# 初期入力
import copy
from itertools import combinations
import sys
input = sys.stdin.readline  #文字列では使わない
N,A,B,C = (int(i) for i in input().split())
l =[0]*N
for i in range(N):
    l[i] = int(input())

# A,B,Cどの竹を選ぶかcombination
mp=[]
for na in range(1,N-1):
    for ja in combinations(l,na):

        l_b =copy.copy(l)
        for i2 in ja:
            if i2 in l_b:
                l_b.remove(i2)
        for nb in range(1,N):
            for jb in combinations(l_b ,nb):

                l_c =copy.copy(l_b)
                for i3 in jb:
                    if i3 in l_c:
                        l_c.remove(i3)
                for nc in range(1,N+1):
                    for jc in combinations(l_c ,nc):
                        
                        # MPの消費量＝（求める長さー今回選んだ竹の長さ合計）+10*（合成魔法の回数)
                        AA =abs(A-sum(ja)) +10*(na-1)
                        BB =abs(B-sum(jb)) +10*(nb-1)
                        CC =abs(C-sum(jc)) +10*(nc-1)
                        mp.append(AA +BB +CC)


print(min(mp)) import copy copy from itertools import combinations import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N,A,B,C = (int(i) for i in input().split()) N (int(i) for i in input().split()) A B C l =[0]*N l [0]*N [0] 0 N for i in range(N):
    l[i] = int(input())

# A,B,Cどの竹を選ぶかcombination i range(N) range N l[i] = int(input()) l[i] l i int(input()) int input() input mp=[] mp [] for na in range(1,N-1):
    for ja in combinations(l,na):

        l_b =copy.copy(l)
        for i2 in ja:
            if i2 in l_b:
                l_b.remove(i2)
        for nb in range(1,N):
            for jb in combinations(l_b ,nb):

                l_c =copy.copy(l_b)
                for i3 in jb:
                    if i3 in l_c:
                        l_c.remove(i3)
                for nc in range(1,N+1):
                    for jc in combinations(l_c ,nc):
                        
                        # MPの消費量＝（求める長さー今回選んだ竹の長さ合計）+10*（合成魔法の回数)
                        AA =abs(A-sum(ja)) +10*(na-1)
                        BB =abs(B-sum(jb)) +10*(nb-1)
                        CC =abs(C-sum(jc)) +10*(nc-1)
                        mp.append(AA +BB +CC) na range(1,N-1) range 1 N-1 N 1 for ja in combinations(l,na):

        l_b =copy.copy(l)
        for i2 in ja:
            if i2 in l_b:
                l_b.remove(i2)
        for nb in range(1,N):
            for jb in combinations(l_b ,nb):

                l_c =copy.copy(l_b)
                for i3 in jb:
                    if i3 in l_c:
                        l_c.remove(i3)
                for nc in range(1,N+1):
                    for jc in combinations(l_c ,nc):
                        
                        # MPの消費量＝（求める長さー今回選んだ竹の長さ合計）+10*（合成魔法の回数)
                        AA =abs(A-sum(ja)) +10*(na-1)
                        BB =abs(B-sum(jb)) +10*(nb-1)
                        CC =abs(C-sum(jc)) +10*(nc-1)
                        mp.append(AA +BB +CC) ja combinations(l,na) combinations l na l_b =copy.copy(l) l_b copy.copy(l) copy.copy copy copy l for i2 in ja:
            if i2 in l_b:
                l_b.remove(i2)
         i2 ja if i2 in l_b:
                l_b.remove(i2)
         i2 in l_b i2 l_b l_b.remove(i2) l_b.remove l_b remove i2 for nb in range(1,N):
            for jb in combinations(l_b ,nb):

                l_c =copy.copy(l_b)
                for i3 in jb:
                    if i3 in l_c:
                        l_c.remove(i3)
                for nc in range(1,N+1):
                    for jc in combinations(l_c ,nc):
                        
                        # MPの消費量＝（求める長さー今回選んだ竹の長さ合計）+10*（合成魔法の回数)
                        AA =abs(A-sum(ja)) +10*(na-1)
                        BB =abs(B-sum(jb)) +10*(nb-1)
                        CC =abs(C-sum(jc)) +10*(nc-1)
                        mp.append(AA +BB +CC) nb range(1,N) range 1 N for jb in combinations(l_b ,nb):

                l_c =copy.copy(l_b)
                for i3 in jb:
                    if i3 in l_c:
                        l_c.remove(i3)
                for nc in range(1,N+1):
                    for jc in combinations(l_c ,nc):
                        
                        # MPの消費量＝（求める長さー今回選んだ竹の長さ合計）+10*（合成魔法の回数)
                        AA =abs(A-sum(ja)) +10*(na-1)
                        BB =abs(B-sum(jb)) +10*(nb-1)
                        CC =abs(C-sum(jc)) +10*(nc-1)
                        mp.append(AA +BB +CC) jb combinations(l_b ,nb) combinations l_b nb l_c =copy.copy(l_b) l_c copy.copy(l_b) copy.copy copy copy l_b for i3 in jb:
                    if i3 in l_c:
                        l_c.remove(i3)
                 i3 jb if i3 in l_c:
                        l_c.remove(i3)
                 i3 in l_c i3 l_c l_c.remove(i3) l_c.remove l_c remove i3 for nc in range(1,N+1):
                    for jc in combinations(l_c ,nc):
                        
                        # MPの消費量＝（求める長さー今回選んだ竹の長さ合計）+10*（合成魔法の回数)
                        AA =abs(A-sum(ja)) +10*(na-1)
                        BB =abs(B-sum(jb)) +10*(nb-1)
                        CC =abs(C-sum(jc)) +10*(nc-1)
                        mp.append(AA +BB +CC) nc range(1,N+1) range 1 N+1 N 1 for jc in combinations(l_c ,nc):
                        
                        # MPの消費量＝（求める長さー今回選んだ竹の長さ合計）+10*（合成魔法の回数)
                        AA =abs(A-sum(ja)) +10*(na-1)
                        BB =abs(B-sum(jb)) +10*(nb-1)
                        CC =abs(C-sum(jc)) +10*(nc-1)
                        mp.append(AA +BB +CC) jc combinations(l_c ,nc) combinations l_c nc AA =abs(A-sum(ja)) +10*(na-1) AA abs(A-sum(ja)) +10*(na-1) abs(A-sum(ja)) abs A-sum(ja) A sum(ja) sum ja 10*(na-1) 10 na-1 na 1 BB =abs(B-sum(jb)) +10*(nb-1) BB abs(B-sum(jb)) +10*(nb-1) abs(B-sum(jb)) abs B-sum(jb) B sum(jb) sum jb 10*(nb-1) 10 nb-1 nb 1 CC =abs(C-sum(jc)) +10*(nc-1) CC abs(C-sum(jc)) +10*(nc-1) abs(C-sum(jc)) abs C-sum(jc) C sum(jc) sum jc 10*(nc-1) 10 nc-1 nc 1 mp.append(AA +BB +CC) mp.append mp append AA +BB +CC AA +BB AA BB CC print(min(mp)) print min(mp) min mp N,A,B,C = (int(i) for i in input().split()) (int(i) for i in input().split()) N mp=[] [] mp A,B,C = (int(i) for i in input().split()) (int(i) for i in input().split()) A l_c =copy.copy(l_b) copy.copy(l_b) l_c BB =abs(B-sum(jb)) +10*(nb-1) abs(B-sum(jb)) +10*(nb-1) BB C = (int(i) for i in input().split()) (int(i) for i in input().split()) C CC =abs(C-sum(jc)) +10*(nc-1) abs(C-sum(jc)) +10*(nc-1) CC l =[0]*N [0]*N l B,C = (int(i) for i in input().split()) (int(i) for i in input().split()) B AA =abs(A-sum(ja)) +10*(na-1) abs(A-sum(ja)) +10*(na-1) AA input = sys.stdin.readline sys.stdin.readline input l_b =copy.copy(l) copy.copy(l) l_b
#全探索をA,B,C一度で分けた
# RE 1   ac 19

# 初期入力
import copy
from itertools import combinations
import sys
input = sys.stdin.readline  #文字列では使わない
N,A,B,C = (int(i) for i in input().split())
l =[0]*N
for i in range(N):
    l[i] = int(input())

# A,B,Cどの竹を選ぶかcombination
mp=[]
for na in range(1,N-1):
    for ja in combinations(l,na):

        l_b =copy.copy(l)
        for i2 in ja:
            if i2 in l_b:
                l_b.remove(i2)
        for nb in range(1,N):
            for jb in combinations(l_b ,nb):

                l_c =copy.copy(l_b)
                for i3 in jb:
                    if i3 in l_c:
                        l_c.remove(i3)
                for nc in range(1,N+1):
                    for jc in combinations(l_c ,nc):
                        
                        # MPの消費量＝（求める長さー今回選んだ竹の長さ合計）+10*（合成魔法の回数)
                        AA =abs(A-sum(ja)) +10*(na-1)
                        BB =abs(B-sum(jb)) +10*(nb-1)
                        CC =abs(C-sum(jc)) +10*(nc-1)
                        mp.append(AA +BB +CC)


print(min(mp))