from itertools import product
import bisect

N, A, B, C = map(int, input().split()) 
tl = [C,B,A]

ll = []
for _ in range(N):
    ll.append(int(input()))



ans = 10**8
ite = product(range(4),repeat=N)
for pattern in ite:
    bag = [[],[],[]]
    singles = []
    mp = 0
    for i, p in enumerate(pattern):
        if p == 3: singles.append(ll[i])
        else: bag[p].append(ll[i])
    
    zero_cnt = 0
    for b in bag:
        if not b: zero_cnt+=1
        else: mp += (len(b)-1)*10
    if not singles: zero_cnt+=1
    if zero_cnt >= 2: continue

    bamboos = []
    for b in bag:
        if b: bamboos.append(sum(b))
    for s in singles:
        bamboos.append(s)

    bamboos.sort()
    # print(bamboos)
    
    for t in tl:
        curr_min = 10000
        curr_min_i = 0
        for i, ba in enumerate(bamboos):
            if abs(ba - t) < curr_min:
                curr_min = abs(ba-t)
                curr_min_i = i
        mp += curr_min
        bamboos.pop(curr_min_i)

    ans = min(ans,mp)

print(ans) from itertools import product import bisect bisect N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C tl = [C,B,A] tl [C,B,A] C B A ll = [] ll [] for _ in range(N):
    ll.append(int(input())) _ range(N) range N ll.append(int(input())) ll.append ll append int(input()) int input() input ans = 10**8 ans 10**8 10 8 ite = product(range(4),repeat=N) ite product(range(4),repeat=N) product range(4) range 4 repeat=N repeat N for pattern in ite:
    bag = [[],[],[]]
    singles = []
    mp = 0
    for i, p in enumerate(pattern):
        if p == 3: singles.append(ll[i])
        else: bag[p].append(ll[i])
    
    zero_cnt = 0
    for b in bag:
        if not b: zero_cnt+=1
        else: mp += (len(b)-1)*10
    if not singles: zero_cnt+=1
    if zero_cnt >= 2: continue

    bamboos = []
    for b in bag:
        if b: bamboos.append(sum(b))
    for s in singles:
        bamboos.append(s)

    bamboos.sort()
    # print(bamboos)
    
    for t in tl:
        curr_min = 10000
        curr_min_i = 0
        for i, ba in enumerate(bamboos):
            if abs(ba - t) < curr_min:
                curr_min = abs(ba-t)
                curr_min_i = i
        mp += curr_min
        bamboos.pop(curr_min_i)

    ans = min(ans,mp) pattern ite bag = [[],[],[]] bag [[],[],[]] [] [] [] singles = [] singles [] mp = 0 mp 0 for i, p in enumerate(pattern):
        if p == 3: singles.append(ll[i])
        else: bag[p].append(ll[i])
    
     i p enumerate(pattern) enumerate pattern if p == 3: singles.append(ll[i])
        else: bag[p].append(ll[i])
    
     p == 3 p 3 zero_cnt = 0 zero_cnt 0 for b in bag:
        if not b: zero_cnt+=1
        else: mp += (len(b)-1)*10
     b bag if not b: zero_cnt+=1
        else: mp += (len(b)-1)*10
     not b b if not singles: zero_cnt+=1
     not singles singles if zero_cnt >= 2: continue

     zero_cnt >= 2 zero_cnt 2 bamboos = [] bamboos [] for b in bag:
        if b: bamboos.append(sum(b))
     b bag if b: bamboos.append(sum(b))
     b for s in singles:
        bamboos.append(s)

     s singles bamboos.append(s) bamboos.append bamboos append s bamboos.sort() bamboos.sort bamboos sort for t in tl:
        curr_min = 10000
        curr_min_i = 0
        for i, ba in enumerate(bamboos):
            if abs(ba - t) < curr_min:
                curr_min = abs(ba-t)
                curr_min_i = i
        mp += curr_min
        bamboos.pop(curr_min_i)

     t tl curr_min = 10000 curr_min 10000 curr_min_i = 0 curr_min_i 0 for i, ba in enumerate(bamboos):
            if abs(ba - t) < curr_min:
                curr_min = abs(ba-t)
                curr_min_i = i
         i ba enumerate(bamboos) enumerate bamboos if abs(ba - t) < curr_min:
                curr_min = abs(ba-t)
                curr_min_i = i
         abs(ba - t) < curr_min abs(ba - t) abs ba - t ba t curr_min curr_min = abs(ba-t) curr_min abs(ba-t) abs ba-t ba t curr_min_i = i curr_min_i i mp += curr_min mp curr_min bamboos.pop(curr_min_i) bamboos.pop bamboos pop curr_min_i ans = min(ans,mp) ans min(ans,mp) min ans mp print(ans) print ans ans = 10**8 10**8 ans singles = [] [] singles tl = [C,B,A] [C,B,A] tl bag = [[],[],[]] [[],[],[]] bag bamboos = [] [] bamboos curr_min_i = i i curr_min_i mp = 0 0 mp B, C = map(int, input().split()) map(int, input().split()) B ite = product(range(4),repeat=N) product(range(4),repeat=N) ite N, A, B, C = map(int, input().split()) map(int, input().split()) N ans = min(ans,mp) min(ans,mp) ans mp += curr_min curr_min mp curr_min = abs(ba-t) abs(ba-t) curr_min ll = [] [] ll A, B, C = map(int, input().split()) map(int, input().split()) A zero_cnt = 0 0 zero_cnt curr_min = 10000 10000 curr_min C = map(int, input().split()) map(int, input().split()) C curr_min_i = 0 0 curr_min_i
from itertools import product
import bisect

N, A, B, C = map(int, input().split()) 
tl = [C,B,A]

ll = []
for _ in range(N):
    ll.append(int(input()))



ans = 10**8
ite = product(range(4),repeat=N)
for pattern in ite:
    bag = [[],[],[]]
    singles = []
    mp = 0
    for i, p in enumerate(pattern):
        if p == 3: singles.append(ll[i])
        else: bag[p].append(ll[i])
    
    zero_cnt = 0
    for b in bag:
        if not b: zero_cnt+=1
        else: mp += (len(b)-1)*10
    if not singles: zero_cnt+=1
    if zero_cnt >= 2: continue

    bamboos = []
    for b in bag:
        if b: bamboos.append(sum(b))
    for s in singles:
        bamboos.append(s)

    bamboos.sort()
    # print(bamboos)
    
    for t in tl:
        curr_min = 10000
        curr_min_i = 0
        for i, ba in enumerate(bamboos):
            if abs(ba - t) < curr_min:
                curr_min = abs(ba-t)
                curr_min_i = i
        mp += curr_min
        bamboos.pop(curr_min_i)

    ans = min(ans,mp)

print(ans)