#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template
ans = 10**18
N,A,B,C = inputlist()
l = [0]*N
for i in range(N):
    l[i] = int(input())

n = 4**N

def count(li,n):
    co = 0
    co += (len(li)-1)*10
    co += abs(sum(li) - n)
    return co

for i in range(n+1):
    k = base10to(i,4)
    if len(k) < N:
        d = N-len(k)
        for j in range(d):
            k = '0'+k
    c = Counter(list(k))
    if c['1'] < 1 or c['2'] < 1 or c['3'] < 1:
        continue
    ans_k = 0
    la = []
    lb = []
    lc = []
    for j in range(N):
        if k[j] == '1':
            la.append(l[j])
        if k[j] == '2':
            lb.append(l[j])
        if k[j] == '3':
            lc.append(l[j])
    ans_k += count(la,A) + count(lb,B) + count(lc,C)
    ans = min(ans,ans_k)
print(ans) from collections import Counter int(k) for k in input().split() for k in input().split() k input().split() ().split () input split for k in input().split() int(k) int k def inputlist(): return [int(k) for k in input().split()] inputlist def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template base10to if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
     int(n/b) int n/b n b return base10to(int(n/b), b) + str(n%b) base10to(int(n/b), b) + str(n%b) base10to(int(n/b), b) base10to int(n/b) int n/b n b b str(n%b) str n%b n b return str(n%b) str(n%b) str n%b n b n n b b ans = 10**18 ans 10**18 10 18 N,A,B,C = inputlist() N inputlist() inputlist 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 n = 4**N n 4**N 4 N def count(li,n):
    co = 0
    co += (len(li)-1)*10
    co += abs(sum(li) - n)
    return co count co = 0 co 0 co += (len(li)-1)*10 co (len(li)-1)*10 len(li)-1 len(li) len li 1 10 co += abs(sum(li) - n) co abs(sum(li) - n) abs sum(li) - n sum(li) sum li n return co co li li n n for i in range(n+1):
    k = base10to(i,4)
    if len(k) < N:
        d = N-len(k)
        for j in range(d):
            k = '0'+k
    c = Counter(list(k))
    if c['1'] < 1 or c['2'] < 1 or c['3'] < 1:
        continue
    ans_k = 0
    la = []
    lb = []
    lc = []
    for j in range(N):
        if k[j] == '1':
            la.append(l[j])
        if k[j] == '2':
            lb.append(l[j])
        if k[j] == '3':
            lc.append(l[j])
    ans_k += count(la,A) + count(lb,B) + count(lc,C)
    ans = min(ans,ans_k) i range(n+1) range n+1 n 1 k = base10to(i,4) k base10to(i,4) base10to i 4 if len(k) < N:
        d = N-len(k)
        for j in range(d):
            k = '0'+k
     len(k) < N len(k) len k N d = N-len(k) d N-len(k) N len(k) len k for j in range(d):
            k = '0'+k
     j range(d) range d k = '0'+k k '0'+k '0' k c = Counter(list(k)) c Counter(list(k)) Counter list(k) list k if c['1'] < 1 or c['2'] < 1 or c['3'] < 1:
        continue
     c['1'] < 1 or c['2'] < 1 or c['3'] < 1 c['1'] < 1 or c['2'] < 1 c['1'] < 1 c['1'] c '1' 1 c['2'] < 1 c['2'] c '2' 1 c['3'] < 1 c['3'] c '3' 1 continue ans_k = 0 ans_k 0 la = [] la [] lb = [] lb [] lc = [] lc [] for j in range(N):
        if k[j] == '1':
            la.append(l[j])
        if k[j] == '2':
            lb.append(l[j])
        if k[j] == '3':
            lc.append(l[j])
     j range(N) range N if k[j] == '1':
            la.append(l[j])
         k[j] == '1' k[j] k j '1' la.append(l[j]) la.append la append l[j] l j if k[j] == '2':
            lb.append(l[j])
         k[j] == '2' k[j] k j '2' lb.append(l[j]) lb.append lb append l[j] l j if k[j] == '3':
            lc.append(l[j])
     k[j] == '3' k[j] k j '3' lc.append(l[j]) lc.append lc append l[j] l j ans_k += count(la,A) + count(lb,B) + count(lc,C) ans_k count(la,A) + count(lb,B) + count(lc,C) count(la,A) + count(lb,B) count(la,A) count la A count(lb,B) count lb B count(lc,C) count lc C ans = min(ans,ans_k) ans min(ans,ans_k) min ans ans_k print(ans) print ans n = 4**N 4**N n la = [] [] la lc = [] [] lc def inputlist(): return [int(k) for k in input().split()] def inputlist(): return [int(k) for k in input().split()] inputlist ans = min(ans,ans_k) min(ans,ans_k) ans lb = [] [] lb k = base10to(i,4) base10to(i,4) k ans = 10**18 10**18 ans def count(li,n):
    co = 0
    co += (len(li)-1)*10
    co += abs(sum(li) - n)
    return co def count(li,n):
    co = 0
    co += (len(li)-1)*10
    co += abs(sum(li) - n)
    return co count d = N-len(k) N-len(k) d ans_k = 0 0 ans_k A,B,C = inputlist() inputlist() A C = inputlist() inputlist() C c = Counter(list(k)) Counter(list(k)) c def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template base10to N,A,B,C = inputlist() inputlist() N k = '0'+k '0'+k k B,C = inputlist() inputlist() B ans_k += count(la,A) + count(lb,B) + count(lc,C) count(la,A) + count(lb,B) + count(lc,C) ans_k l = [0]*N [0]*N l
#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template
ans = 10**18
N,A,B,C = inputlist()
l = [0]*N
for i in range(N):
    l[i] = int(input())

n = 4**N

def count(li,n):
    co = 0
    co += (len(li)-1)*10
    co += abs(sum(li) - n)
    return co

for i in range(n+1):
    k = base10to(i,4)
    if len(k) < N:
        d = N-len(k)
        for j in range(d):
            k = '0'+k
    c = Counter(list(k))
    if c['1'] < 1 or c['2'] < 1 or c['3'] < 1:
        continue
    ans_k = 0
    la = []
    lb = []
    lc = []
    for j in range(N):
        if k[j] == '1':
            la.append(l[j])
        if k[j] == '2':
            lb.append(l[j])
        if k[j] == '3':
            lc.append(l[j])
    ans_k += count(la,A) + count(lb,B) + count(lc,C)
    ans = min(ans,ans_k)
print(ans)
