### BUGGY CODE ###

n, a, b, c = [int(x) for x in input().split()]
l = [int(input()) for i in range(n)]

# 合成を使わないとき
def move(a, b, c ,l):
    ''' a, b, c = int, l = list'''

    x = []
    for i in range(len(l)):
        c_abs = abs(c - l[i])
        m = l[:]
        m.pop(i)
        for j in range(len(m)):
            b_abs = abs(b - m[j])
            p = m[:]
            p.pop(j)
            for k in range(len(p)):
                a_abs = abs(a - p[k])
                x.append(c_abs + b_abs + a_abs)
    return min(x)

# 合成を使う時
def merge(l):
    ''' return possible l list'''

    mp = 0
    if len(l) == 3:
        return l, mp
    a = []
    mp = 10
    for i in range(len(l) - 1):
        x = l[i]
        m = l[:]
        m.pop(i)
        for j in range(len(m)):
            if j < i:
                continue
            y = m[j]
            p = m[:]
            p.pop(j)
            p.append(x + y)
            a.append(p)
    return a, mp

def answer(n, a, b, c, l):
    y = move(a, b, c, l)
    mp = [y]

    if n == 3:
        return mp[0]
    l_new, mp_add = merge(l)
    for i in l_new:
        mp.append(move(a, b, c, i) + mp_add)
        # n = 4 のとき
        if n == 4:
            continue #return = min(mp)
        l_new1, mp_add1 = merge(i)
        for j in l_new1:
            mp.append(move(a, b, c, j) + mp_add + mp_add1)
            # n = 5のとき
            if n == 5:
                continue #return = min(mp)
            l_new2, mp_add2 = merge(j)
            for k in l_new2:
                mp.append(move(a, b, c, k) + mp_add + mp_add1 + mp_add2)
                # n == 6
                if n == 6:
                    continue #return min(mp)
                l_new3, mp_add3 = merge(k)
                for p in l_new3:
                    mp.append(move(a, b, c, p) + mp_add + mp_add1 + mp_add2 + mp_add3)
                    # n == 7
                    if n == 7:
                        continue #return min(mp)
                    l_new4, mp_add4 = merge(p)
                    for q in l_new4:
                        mp.append(move(a, b, c, q) + mp_add + mp_add1 + mp_add2 + mp_add3 + mp_add4)
                        # n == 8
                        if n == 8:
                            continue #return min(mp)
    else:
        return min(mp)

print(answer(n, a, b, c, l))


### FIXED CODE ###

n, a, b, c = [int(x) for x in input().split()]
l = [int(input()) for i in range(n)]


label = ['a', 'b', 'c', 'd']
list_init = []
for i in label:
    for j in label:
        list_init.append([i, j])

def extend(list):
    if n == 2:
        return list
    list_new = []
    for i in list[:]:
        for j in label:
            i.append(j)
            list_new.append(i[:])
            i.pop()
    if len(list_new[0]) == n:
        return list_new
    else:
        return extend(list_new[:])

list_created = extend(list_init[:])
mp = []
INF = 10 ** 9
for i in list_created:
    s = set(i)
    try: s.remove('d')
    except KeyError: pass
    if len(s) < 3:
        mp.append(INF)
        continue

    la, lb, lc = 0, 0, 0
    na, nb, nc = 0, 0, 0
    for j in range(len(i)):
        if i[j] == 'a':
            la += l[j]
            na += 1
        elif i[j] == 'b':
            lb += l[j]
            nb += 1
        elif i[j] == 'c':
            lc += l[j]
            nc += 1
    mp.append(abs(la-a) + abs(lb-b) + abs(lc-c) + 10*(na + nb + nc - 3))

print(min(mp))