# C - Synthetic Kadomatsu
'''
100, 90, 80
98, 80, 40, 30, 21
L[0]〜L[N-1]がそれぞれ、A,B,C,使わないのいずれかかを考える。
4**8=65536
'''
import itertools
INF = 10**18
N, A, B, C = map(int, input().split())
L = [0] * N
for i in range(N):
    L[i] = int(input())
    
c = (0, 1, 2, 3) # 3は使わない
ans = INF

for comb in itertools.product(c,repeat=N):
    tmp = [0]*4 
    ansArr = [0]*3
    #print(comb)
    for i, j in enumerate(comb):
        if tmp[j]==0:
            tmp[j] += L[i]
        elif j!=3:
            tmp[j] += L[i]
            ansArr[j] += 10
    if tmp[0]==0 or tmp[1]==0 or tmp[2]==0:
        continue
    ansArr[0] += abs(A-tmp[0])
    ansArr[1] += abs(B-tmp[1])        
    ansArr[2] += abs(C-tmp[2])
    #print(tmp)
    #print(ansArr)
    ans = min(ans, sum(ansArr))
    #print(ans)

print(ans) '''
100, 90, 80
98, 80, 40, 30, 21
L[0]〜L[N-1]がそれぞれ、A,B,C,使わないのいずれかかを考える。
4**8=65536
''' import itertools itertools INF = 10**18 INF 10**18 10 18 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 c = (0, 1, 2, 3) c (0, 1, 2, 3) 0 1 2 3 ans = INF ans INF for comb in itertools.product(c,repeat=N):
    tmp = [0]*4 
    ansArr = [0]*3
    #print(comb)
    for i, j in enumerate(comb):
        if tmp[j]==0:
            tmp[j] += L[i]
        elif j!=3:
            tmp[j] += L[i]
            ansArr[j] += 10
    if tmp[0]==0 or tmp[1]==0 or tmp[2]==0:
        continue
    ansArr[0] += abs(A-tmp[0])
    ansArr[1] += abs(B-tmp[1])        
    ansArr[2] += abs(C-tmp[2])
    #print(tmp)
    #print(ansArr)
    ans = min(ans, sum(ansArr))
    #print(ans) comb itertools.product(c,repeat=N) itertools.product itertools product c repeat=N repeat N tmp = [0]*4 tmp [0]*4 [0] 0 4 ansArr = [0]*3 ansArr [0]*3 [0] 0 3 for i, j in enumerate(comb):
        if tmp[j]==0:
            tmp[j] += L[i]
        elif j!=3:
            tmp[j] += L[i]
            ansArr[j] += 10
     i j enumerate(comb) enumerate comb if tmp[j]==0:
            tmp[j] += L[i]
        elif j!=3:
            tmp[j] += L[i]
            ansArr[j] += 10
     tmp[j]==0 tmp[j] tmp j 0 tmp[j] += L[i] tmp[j] tmp j L[i] L i elif j!=3:
            tmp[j] += L[i]
            ansArr[j] += 10
     j!=3 j 3 tmp[j] += L[i] tmp[j] tmp j L[i] L i ansArr[j] += 10 ansArr[j] ansArr j 10 if tmp[0]==0 or tmp[1]==0 or tmp[2]==0:
        continue
     tmp[0]==0 or tmp[1]==0 or tmp[2]==0 tmp[0]==0 or tmp[1]==0 tmp[0]==0 tmp[0] tmp 0 0 tmp[1]==0 tmp[1] tmp 1 0 tmp[2]==0 tmp[2] tmp 2 0 continue ansArr[0] += abs(A-tmp[0]) ansArr[0] ansArr 0 abs(A-tmp[0]) abs A-tmp[0] A tmp[0] tmp 0 ansArr[1] += abs(B-tmp[1]) ansArr[1] ansArr 1 abs(B-tmp[1]) abs B-tmp[1] B tmp[1] tmp 1 ansArr[2] += abs(C-tmp[2]) ansArr[2] ansArr 2 abs(C-tmp[2]) abs C-tmp[2] C tmp[2] tmp 2 ans = min(ans, sum(ansArr)) ans min(ans, sum(ansArr)) min ans sum(ansArr) sum ansArr print(ans) print ans C = map(int, input().split()) map(int, input().split()) C A, B, C = map(int, input().split()) map(int, input().split()) A ans = min(ans, sum(ansArr)) min(ans, sum(ansArr)) ans INF = 10**18 10**18 INF c = (0, 1, 2, 3) (0, 1, 2, 3) c N, A, B, C = map(int, input().split()) map(int, input().split()) N ans = INF INF ans B, C = map(int, input().split()) map(int, input().split()) B L = [0] * N [0] * N L tmp = [0]*4 [0]*4 tmp ansArr = [0]*3 [0]*3 ansArr
# C - Synthetic Kadomatsu
'''
100, 90, 80
98, 80, 40, 30, 21
L[0]〜L[N-1]がそれぞれ、A,B,C,使わないのいずれかかを考える。
4**8=65536
'''
import itertools
INF = 10**18
N, A, B, C = map(int, input().split())
L = [0] * N
for i in range(N):
    L[i] = int(input())
    
c = (0, 1, 2, 3) # 3は使わない
ans = INF

for comb in itertools.product(c,repeat=N):
    tmp = [0]*4 
    ansArr = [0]*3
    #print(comb)
    for i, j in enumerate(comb):
        if tmp[j]==0:
            tmp[j] += L[i]
        elif j!=3:
            tmp[j] += L[i]
            ansArr[j] += 10
    if tmp[0]==0 or tmp[1]==0 or tmp[2]==0:
        continue
    ansArr[0] += abs(A-tmp[0])
    ansArr[1] += abs(B-tmp[1])        
    ansArr[2] += abs(C-tmp[2])
    #print(tmp)
    #print(ansArr)
    ans = min(ans, sum(ansArr))
    #print(ans)

print(ans)