n,a,b,c = map(int,input().split())
l = []
for i in range(n):
    l.append(int(input()))
mi = 10**18
aa = []
ba = []
ca = []
da = []
def dfs(ai,bi,ci,di,i):
    global mi
    if i == n:
        if len(ai) == 0 or len(bi) == 0 or len(ci) == 0:
            return mi
        tmp = 0
        if len(ai) > 1:
            tmp += 10 * (len(ai) - 1)
        if len(bi) > 1:
            tmp += 10 * (len(bi) - 1)
        if len(ci) > 1:
            tmp += 10 * (len(ci) - 1)
        tmp += abs(a - sum(ai))
        tmp += abs(b - sum(bi))
        tmp += abs(c - sum(ci))
        mi = min(mi,tmp)
        return mi
    else:
        return min(min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)),min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1)))
print(dfs(aa,ba,ca,da,0)) 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 mi = 10**18 mi 10**18 10 18 aa = [] aa [] ba = [] ba [] ca = [] ca [] da = [] da [] def dfs(ai,bi,ci,di,i):
    global mi
    if i == n:
        if len(ai) == 0 or len(bi) == 0 or len(ci) == 0:
            return mi
        tmp = 0
        if len(ai) > 1:
            tmp += 10 * (len(ai) - 1)
        if len(bi) > 1:
            tmp += 10 * (len(bi) - 1)
        if len(ci) > 1:
            tmp += 10 * (len(ci) - 1)
        tmp += abs(a - sum(ai))
        tmp += abs(b - sum(bi))
        tmp += abs(c - sum(ci))
        mi = min(mi,tmp)
        return mi
    else:
        return min(min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)),min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1))) dfs global mi if i == n:
        if len(ai) == 0 or len(bi) == 0 or len(ci) == 0:
            return mi
        tmp = 0
        if len(ai) > 1:
            tmp += 10 * (len(ai) - 1)
        if len(bi) > 1:
            tmp += 10 * (len(bi) - 1)
        if len(ci) > 1:
            tmp += 10 * (len(ci) - 1)
        tmp += abs(a - sum(ai))
        tmp += abs(b - sum(bi))
        tmp += abs(c - sum(ci))
        mi = min(mi,tmp)
        return mi
    else:
        return min(min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)),min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1))) i == n i n if len(ai) == 0 or len(bi) == 0 or len(ci) == 0:
            return mi
         len(ai) == 0 or len(bi) == 0 or len(ci) == 0 len(ai) == 0 or len(bi) == 0 len(ai) == 0 len(ai) len ai 0 len(bi) == 0 len(bi) len bi 0 len(ci) == 0 len(ci) len ci 0 return mi mi tmp = 0 tmp 0 if len(ai) > 1:
            tmp += 10 * (len(ai) - 1)
         len(ai) > 1 len(ai) len ai 1 tmp += 10 * (len(ai) - 1) tmp 10 * (len(ai) - 1) 10 len(ai) - 1 len(ai) len ai 1 if len(bi) > 1:
            tmp += 10 * (len(bi) - 1)
         len(bi) > 1 len(bi) len bi 1 tmp += 10 * (len(bi) - 1) tmp 10 * (len(bi) - 1) 10 len(bi) - 1 len(bi) len bi 1 if len(ci) > 1:
            tmp += 10 * (len(ci) - 1)
         len(ci) > 1 len(ci) len ci 1 tmp += 10 * (len(ci) - 1) tmp 10 * (len(ci) - 1) 10 len(ci) - 1 len(ci) len ci 1 tmp += abs(a - sum(ai)) tmp abs(a - sum(ai)) abs a - sum(ai) a sum(ai) sum ai tmp += abs(b - sum(bi)) tmp abs(b - sum(bi)) abs b - sum(bi) b sum(bi) sum bi tmp += abs(c - sum(ci)) tmp abs(c - sum(ci)) abs c - sum(ci) c sum(ci) sum ci mi = min(mi,tmp) mi min(mi,tmp) min mi tmp return mi mi return min(min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)),min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1))) min(min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)),min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1))) min min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)) min dfs(ai+[l[i]],bi,ci,di,i+1) dfs ai+[l[i]] ai [l[i]] l[i] l i bi ci di i+1 i 1 dfs(ai,bi+[l[i]],ci,di,i+1) dfs ai bi+[l[i]] bi [l[i]] l[i] l i ci di i+1 i 1 min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1)) min dfs(ai,bi,ci+[l[i]],di,i+1) dfs ai bi ci+[l[i]] ci [l[i]] l[i] l i di i+1 i 1 dfs(ai,bi,ci,di+[l[i]],i+1) dfs ai bi ci di+[l[i]] di [l[i]] l[i] l i i+1 i 1 ai ai bi bi ci ci di di i i print(dfs(aa,ba,ca,da,0)) print dfs(aa,ba,ca,da,0) dfs aa ba ca da 0 l = [] [] l da = [] [] da a,b,c = map(int,input().split()) map(int,input().split()) a ba = [] [] ba c = map(int,input().split()) map(int,input().split()) c ca = [] [] ca mi = 10**18 10**18 mi aa = [] [] aa def dfs(ai,bi,ci,di,i):
    global mi
    if i == n:
        if len(ai) == 0 or len(bi) == 0 or len(ci) == 0:
            return mi
        tmp = 0
        if len(ai) > 1:
            tmp += 10 * (len(ai) - 1)
        if len(bi) > 1:
            tmp += 10 * (len(bi) - 1)
        if len(ci) > 1:
            tmp += 10 * (len(ci) - 1)
        tmp += abs(a - sum(ai))
        tmp += abs(b - sum(bi))
        tmp += abs(c - sum(ci))
        mi = min(mi,tmp)
        return mi
    else:
        return min(min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)),min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1))) def dfs(ai,bi,ci,di,i):
    global mi
    if i == n:
        if len(ai) == 0 or len(bi) == 0 or len(ci) == 0:
            return mi
        tmp = 0
        if len(ai) > 1:
            tmp += 10 * (len(ai) - 1)
        if len(bi) > 1:
            tmp += 10 * (len(bi) - 1)
        if len(ci) > 1:
            tmp += 10 * (len(ci) - 1)
        tmp += abs(a - sum(ai))
        tmp += abs(b - sum(bi))
        tmp += abs(c - sum(ci))
        mi = min(mi,tmp)
        return mi
    else:
        return min(min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)),min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1))) dfs n,a,b,c = map(int,input().split()) map(int,input().split()) n b,c = map(int,input().split()) map(int,input().split()) b
n,a,b,c = map(int,input().split())
l = []
for i in range(n):
    l.append(int(input()))
mi = 10**18
aa = []
ba = []
ca = []
da = []
def dfs(ai,bi,ci,di,i):
    global mi
    if i == n:
        if len(ai) == 0 or len(bi) == 0 or len(ci) == 0:
            return mi
        tmp = 0
        if len(ai) > 1:
            tmp += 10 * (len(ai) - 1)
        if len(bi) > 1:
            tmp += 10 * (len(bi) - 1)
        if len(ci) > 1:
            tmp += 10 * (len(ci) - 1)
        tmp += abs(a - sum(ai))
        tmp += abs(b - sum(bi))
        tmp += abs(c - sum(ci))
        mi = min(mi,tmp)
        return mi
    else:
        return min(min(dfs(ai+[l[i]],bi,ci,di,i+1),dfs(ai,bi+[l[i]],ci,di,i+1)),min(dfs(ai,bi,ci+[l[i]],di,i+1),dfs(ai,bi,ci,di+[l[i]],i+1)))
print(dfs(aa,ba,ca,da,0))