import itertools

n, a, b, c = list(map(int, input().split()))

f = [a, b, c]
l = [int(input()) for _ in range(n)]

x = [0, 1, 2, 3]

mp_min = 10000

for sublist in itertools.product(x, repeat = n):
    flag = True
    mp = 0
    length = [0] * 3
    for j in range(n):
        d = sublist[j]
        if  d != 3:
            if length[d] == 0:
                length[d] = l[j]
            else:
                length[d] += l[j]
                mp += 10
    
    for k in range(3):
        if length[k] == 0:
            flag = False
            break
        else:
            mp += abs(length[k] - f[k])

    if flag:
        mp_min = min(mp_min, mp)

print(mp_min) import itertools itertools n, a, b, c = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split a b c f = [a, b, c] f [a, b, c] a b c int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] x = [0, 1, 2, 3] x [0, 1, 2, 3] 0 1 2 3 mp_min = 10000 mp_min 10000 for sublist in itertools.product(x, repeat = n):
    flag = True
    mp = 0
    length = [0] * 3
    for j in range(n):
        d = sublist[j]
        if  d != 3:
            if length[d] == 0:
                length[d] = l[j]
            else:
                length[d] += l[j]
                mp += 10
    
    for k in range(3):
        if length[k] == 0:
            flag = False
            break
        else:
            mp += abs(length[k] - f[k])

    if flag:
        mp_min = min(mp_min, mp) sublist itertools.product(x, repeat = n) itertools.product itertools product x repeat = n repeat n flag = True flag True mp = 0 mp 0 length = [0] * 3 length [0] * 3 [0] 0 3 for j in range(n):
        d = sublist[j]
        if  d != 3:
            if length[d] == 0:
                length[d] = l[j]
            else:
                length[d] += l[j]
                mp += 10
    
     j range(n) range n d = sublist[j] d sublist[j] sublist j if  d != 3:
            if length[d] == 0:
                length[d] = l[j]
            else:
                length[d] += l[j]
                mp += 10
    
     d != 3 d 3 if length[d] == 0:
                length[d] = l[j]
            else:
                length[d] += l[j]
                mp += 10
    
     length[d] == 0 length[d] length d 0 length[d] = l[j] length[d] length d l[j] l j length[d] += l[j] length[d] length d l[j] l j mp += 10 mp 10 for k in range(3):
        if length[k] == 0:
            flag = False
            break
        else:
            mp += abs(length[k] - f[k])

     k range(3) range 3 if length[k] == 0:
            flag = False
            break
        else:
            mp += abs(length[k] - f[k])

     length[k] == 0 length[k] length k 0 flag = False flag False break mp += abs(length[k] - f[k]) mp abs(length[k] - f[k]) abs length[k] - f[k] length[k] length k f[k] f k if flag:
        mp_min = min(mp_min, mp) flag mp_min = min(mp_min, mp) mp_min min(mp_min, mp) min mp_min mp print(mp_min) print mp_min b, c = list(map(int, input().split())) list(map(int, input().split())) b mp = 0 0 mp flag = False False flag d = sublist[j] sublist[j] d mp += 10 10 mp flag = True True flag a, b, c = list(map(int, input().split())) list(map(int, input().split())) a c = list(map(int, input().split())) list(map(int, input().split())) c f = [a, b, c] [a, b, c] f length = [0] * 3 [0] * 3 length mp += abs(length[k] - f[k]) abs(length[k] - f[k]) mp mp_min = min(mp_min, mp) min(mp_min, mp) mp_min mp_min = 10000 10000 mp_min l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l n, a, b, c = list(map(int, input().split())) list(map(int, input().split())) n x = [0, 1, 2, 3] [0, 1, 2, 3] x
import itertools

n, a, b, c = list(map(int, input().split()))

f = [a, b, c]
l = [int(input()) for _ in range(n)]

x = [0, 1, 2, 3]

mp_min = 10000

for sublist in itertools.product(x, repeat = n):
    flag = True
    mp = 0
    length = [0] * 3
    for j in range(n):
        d = sublist[j]
        if  d != 3:
            if length[d] == 0:
                length[d] = l[j]
            else:
                length[d] += l[j]
                mp += 10
    
    for k in range(3):
        if length[k] == 0:
            flag = False
            break
        else:
            mp += abs(length[k] - f[k])

    if flag:
        mp_min = min(mp_min, mp)

print(mp_min)