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))
