n,a,b,c = map(int,input().split())
L = []
for i in range(n):
    L.append(int(input()))
import itertools
ans = 10**9
tmp = 0
for perm in itertools.permutations(range(n),3):
    ua,ub,uc = perm
    la,lb,lc = L[ua],L[ub],L[uc]
    for use in itertools.product([0,1,2,-1] ,repeat=n-3):
        idx = 0
        tmp = 0
        ls = [la,lb,lc]
        for i,l in enumerate(L):
            if i== ua or  i== ub or i== uc:
                continue
            else:
                if use[idx]>-1:
                    ls[use[idx]] +=l
                    tmp+=10
            idx+=1
        tmp = tmp + abs(ls[0] -a) +abs(ls[1] -b)+abs(ls[2] -c)
        ans=min(ans,tmp)
print(ans) n,a,b,c = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split a b c L = [] L [] for i in range(n):
    L.append(int(input())) i range(n) range n L.append(int(input())) L.append L append int(input()) int input() input import itertools itertools ans = 10**9 ans 10**9 10 9 tmp = 0 tmp 0 for perm in itertools.permutations(range(n),3):
    ua,ub,uc = perm
    la,lb,lc = L[ua],L[ub],L[uc]
    for use in itertools.product([0,1,2,-1] ,repeat=n-3):
        idx = 0
        tmp = 0
        ls = [la,lb,lc]
        for i,l in enumerate(L):
            if i== ua or  i== ub or i== uc:
                continue
            else:
                if use[idx]>-1:
                    ls[use[idx]] +=l
                    tmp+=10
            idx+=1
        tmp = tmp + abs(ls[0] -a) +abs(ls[1] -b)+abs(ls[2] -c)
        ans=min(ans,tmp) perm itertools.permutations(range(n),3) itertools.permutations itertools permutations range(n) range n 3 ua,ub,uc = perm ua perm ub uc la,lb,lc = L[ua],L[ub],L[uc] la L[ua] L ua lb L[ub] L ub lc L[uc] L uc for use in itertools.product([0,1,2,-1] ,repeat=n-3):
        idx = 0
        tmp = 0
        ls = [la,lb,lc]
        for i,l in enumerate(L):
            if i== ua or  i== ub or i== uc:
                continue
            else:
                if use[idx]>-1:
                    ls[use[idx]] +=l
                    tmp+=10
            idx+=1
        tmp = tmp + abs(ls[0] -a) +abs(ls[1] -b)+abs(ls[2] -c)
        ans=min(ans,tmp) use itertools.product([0,1,2,-1] ,repeat=n-3) itertools.product itertools product [0,1,2,-1] 0 1 2 -1 repeat=n-3 repeat n-3 n 3 idx = 0 idx 0 tmp = 0 tmp 0 ls = [la,lb,lc] ls [la,lb,lc] la lb lc for i,l in enumerate(L):
            if i== ua or  i== ub or i== uc:
                continue
            else:
                if use[idx]>-1:
                    ls[use[idx]] +=l
                    tmp+=10
            idx+=1
         i l enumerate(L) enumerate L if i== ua or  i== ub or i== uc:
                continue
            else:
                if use[idx]>-1:
                    ls[use[idx]] +=l
                    tmp+=10
             i== ua or  i== ub or i== uc i== ua or  i== ub i== ua i ua i== ub i ub i== uc i uc continue if use[idx]>-1:
                    ls[use[idx]] +=l
                    tmp+=10
             use[idx]>-1 use[idx] use idx -1 ls[use[idx]] +=l ls[use[idx]] ls use[idx] use idx l tmp+=10 tmp 10 idx+=1 idx 1 tmp = tmp + abs(ls[0] -a) +abs(ls[1] -b)+abs(ls[2] -c) tmp tmp + abs(ls[0] -a) +abs(ls[1] -b)+abs(ls[2] -c) tmp + abs(ls[0] -a) +abs(ls[1] -b) tmp + abs(ls[0] -a) tmp abs(ls[0] -a) abs ls[0] -a ls[0] ls 0 a abs(ls[1] -b) abs ls[1] -b ls[1] ls 1 b abs(ls[2] -c) abs ls[2] -c ls[2] ls 2 c ans=min(ans,tmp) ans min(ans,tmp) min ans tmp print(ans) print ans a,b,c = map(int,input().split()) map(int,input().split()) a b,c = map(int,input().split()) map(int,input().split()) b idx = 0 0 idx L = [] [] L idx+=1 1 idx tmp = tmp + abs(ls[0] -a) +abs(ls[1] -b)+abs(ls[2] -c) tmp + abs(ls[0] -a) +abs(ls[1] -b)+abs(ls[2] -c) tmp n,a,b,c = map(int,input().split()) map(int,input().split()) n lb,lc = L[ua],L[ub],L[uc] L[ub] lb ans=min(ans,tmp) min(ans,tmp) ans la,lb,lc = L[ua],L[ub],L[uc] L[ua] la ls = [la,lb,lc] [la,lb,lc] ls ub,uc = perm perm ub ans = 10**9 10**9 ans tmp = 0 0 tmp ua,ub,uc = perm perm ua tmp = 0 0 tmp tmp+=10 10 tmp c = map(int,input().split()) map(int,input().split()) c lc = L[ua],L[ub],L[uc] L[uc] lc uc = perm perm uc
n,a,b,c = map(int,input().split())
L = []
for i in range(n):
    L.append(int(input()))
import itertools
ans = 10**9
tmp = 0
for perm in itertools.permutations(range(n),3):
    ua,ub,uc = perm
    la,lb,lc = L[ua],L[ub],L[uc]
    for use in itertools.product([0,1,2,-1] ,repeat=n-3):
        idx = 0
        tmp = 0
        ls = [la,lb,lc]
        for i,l in enumerate(L):
            if i== ua or  i== ub or i== uc:
                continue
            else:
                if use[idx]>-1:
                    ls[use[idx]] +=l
                    tmp+=10
            idx+=1
        tmp = tmp + abs(ls[0] -a) +abs(ls[1] -b)+abs(ls[2] -c)
        ans=min(ans,tmp)
print(ans)
