import numpy as np
import copy
N, A, B, C = map(int,input().split())
t = sorted([A,B,C])
A = t[0]
B = t[1]
C = t[2]
l = []
for i in range(N):
    l.append(int(input()))
dic = {}

def calc(ls):
    dic[tuple(ls)] = 0
    #print([np.abs(i-A) for i in ls])
    Asublist = [np.abs(i-A) for i in ls]
    #Asublist = list(sorted([np.abs(i-A) for i in ls]))[0:2]
    Bsublist = list(sorted([np.abs(i-B) for i in ls]))[0:2]
    Csublist = list(sorted([np.abs(i-C) for i in ls]))[0:2]
    res = min(Asublist)
    idx = Asublist.index(res)
    ls.remove(ls[idx])

    Bsublist = [np.abs(i-B) for i in ls]
    tmp = min(Bsublist)
    res += tmp
    idx = Bsublist.index(tmp)
    ls.remove(ls[idx])

    Csublist = [np.abs(i-C) for i in ls]
    tmp = min(Csublist)
    res += tmp
    idx = Csublist.index(tmp)
    ls.remove(ls[idx])

    #dic[tuple(ls)] = res
    return res + 10*(N - (len(ls)+3))

def rec(ls, num, maxcomb, minval):
    if num == 1:
        minval = calc(copy.deepcopy(ls))
    count = 0
    for i in range(0, len(ls)-1):
        for j in range(i+1, len(ls)):
            tmp = [ls[i]+ls[j]]
            tmp = tmp + [ls[k] for k in range(len(ls)) if k!=i and k!=j]
            #print(tmp)
            if tuple(tmp) in dic.keys():
                continue
            tmp2 = calc(copy.deepcopy(tmp))
            #print([minval, tmp2])
            if minval > tmp2:
                minval = tmp2
            if num < maxcomb:
                #print([i,j,num])
                #print(tmp)
                tmp3 = rec(copy.deepcopy(tmp), num+1, maxcomb, minval)
                if minval > tmp3:
                    minval = tmp3
    return minval
minval = rec(l, 1, N-3, np.inf)
print(minval)
