#bit全探索の亜種(4種全探索)
#itertools.product([0,1,2,3],repeat=N)

import itertools
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(0,N,1)]

ans = 10**10
for ABCD in itertools.product([0,1,2,3],repeat=N):
    tmp = [[] for i in range(4)]
    for i in range(0,N,1):
        tmp[ABCD[i]].append(l[i])
    score = 0
    owaowari = False
    for i in range(3):#Dはくっ付ける必要なし
        if len(tmp[i])==0:
            owaowari = True
            break
        score+=10*max(len(tmp[i])-1,0)
    if owaowari: continue
    score+=abs(A-sum(tmp[0]))
    score+=abs(B-sum(tmp[1]))
    score+=abs(C-sum(tmp[2]))
    ans = min(ans,score)


print(ans) import itertools itertools N,A,B,C = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split A B C int(input()) for i in range(0,N,1) for i in range(0,N,1) i range(0,N,1) range 0 N 1 for i in range(0,N,1) int(input()) int input() input l = [int(input()) for i in range(0,N,1)] l [int(input()) for i in range(0,N,1)] ans = 10**10 ans 10**10 10 10 for ABCD in itertools.product([0,1,2,3],repeat=N):
    tmp = [[] for i in range(4)]
    for i in range(0,N,1):
        tmp[ABCD[i]].append(l[i])
    score = 0
    owaowari = False
    for i in range(3):#Dはくっ付ける必要なし
        if len(tmp[i])==0:
            owaowari = True
            break
        score+=10*max(len(tmp[i])-1,0)
    if owaowari: continue
    score+=abs(A-sum(tmp[0]))
    score+=abs(B-sum(tmp[1]))
    score+=abs(C-sum(tmp[2]))
    ans = min(ans,score) ABCD itertools.product([0,1,2,3],repeat=N) itertools.product itertools product [0,1,2,3] 0 1 2 3 repeat=N repeat N [] for i in range(4) for i in range(4) i range(4) range 4 for i in range(4) [] tmp = [[] for i in range(4)] tmp [[] for i in range(4)] for i in range(0,N,1):
        tmp[ABCD[i]].append(l[i])
     i range(0,N,1) range 0 N 1 tmp[ABCD[i]].append(l[i]) [ABCD[i]].append [ABCD[i]] tmp ABCD[i] ABCD i append l[i] l i score = 0 score 0 owaowari = False owaowari False for i in range(3):#Dはくっ付ける必要なし
        if len(tmp[i])==0:
            owaowari = True
            break
        score+=10*max(len(tmp[i])-1,0)
     i range(3) range 3 if len(tmp[i])==0:
            owaowari = True
            break
         len(tmp[i])==0 len(tmp[i]) len tmp[i] tmp i 0 owaowari = True owaowari True break score+=10*max(len(tmp[i])-1,0) score 10*max(len(tmp[i])-1,0) 10 max(len(tmp[i])-1,0) max len(tmp[i])-1 len(tmp[i]) len tmp[i] tmp i 1 0 if owaowari: continue
     owaowari score+=abs(A-sum(tmp[0])) score abs(A-sum(tmp[0])) abs A-sum(tmp[0]) A sum(tmp[0]) sum tmp[0] tmp 0 score+=abs(B-sum(tmp[1])) score abs(B-sum(tmp[1])) abs B-sum(tmp[1]) B sum(tmp[1]) sum tmp[1] tmp 1 score+=abs(C-sum(tmp[2])) score abs(C-sum(tmp[2])) abs C-sum(tmp[2]) C sum(tmp[2]) sum tmp[2] tmp 2 ans = min(ans,score) ans min(ans,score) min ans score print(ans) print ans score = 0 0 score tmp = [[] for i in range(4)] [[] for i in range(4)] tmp B,C = map(int,input().split()) map(int,input().split()) B owaowari = False False owaowari score+=abs(A-sum(tmp[0])) abs(A-sum(tmp[0])) score ans = min(ans,score) min(ans,score) ans l = [int(input()) for i in range(0,N,1)] [int(input()) for i in range(0,N,1)] l score+=abs(C-sum(tmp[2])) abs(C-sum(tmp[2])) score N,A,B,C = map(int,input().split()) map(int,input().split()) N A,B,C = map(int,input().split()) map(int,input().split()) A ans = 10**10 10**10 ans owaowari = True True owaowari score+=abs(B-sum(tmp[1])) abs(B-sum(tmp[1])) score C = map(int,input().split()) map(int,input().split()) C score+=10*max(len(tmp[i])-1,0) 10*max(len(tmp[i])-1,0) score
#bit全探索の亜種(4種全探索)
#itertools.product([0,1,2,3],repeat=N)

import itertools
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(0,N,1)]

ans = 10**10
for ABCD in itertools.product([0,1,2,3],repeat=N):
    tmp = [[] for i in range(4)]
    for i in range(0,N,1):
        tmp[ABCD[i]].append(l[i])
    score = 0
    owaowari = False
    for i in range(3):#Dはくっ付ける必要なし
        if len(tmp[i])==0:
            owaowari = True
            break
        score+=10*max(len(tmp[i])-1,0)
    if owaowari: continue
    score+=abs(A-sum(tmp[0]))
    score+=abs(B-sum(tmp[1]))
    score+=abs(C-sum(tmp[2]))
    ans = min(ans,score)


print(ans)
