import copy

N,A,B,C = map(int,raw_input().split())
take = [A,B,C]

l = [map(int,(raw_input()+' 0 0 0').split()) for i in range(N)]

ans = 0
flag = [0,0,0]
for i in range(N):
    l[i][1] = abs(A-l[i][0])
    l[i][2] = abs(B-l[i][0])
    l[i][3] = abs(C-l[i][0])

l.sort(key = lambda x:x[1])
if l[0][1] < 10:
    ans += l[0][1]
    flag[0] = 1
    del l[0]

l.sort(key = lambda x:x[2])
if l[0][2] < 10:
    ans += l[0][2]
    flag[1] = 1
    del l[0]

l.sort(key = lambda x:x[3])
if l[0][3] < 10:
    ans += l[0][3]
    flag[2] = 1
    del l[0]

for i in [0,1,2]:
    minimam = 10000000000000
    sayonara = []
    if flag[i] == 1:
        continue
    for j in xrange(2**len(l)-1):
        ret = -10
        cnt = 0
        length = 0
        data = []
        while cnt < len(l):
            if j%2 == 0: #siyou
                ret += 10
                length += l[cnt][0]
                data.append(1)
            else:
                data.append(0)
            j /= 2
            cnt += 1
        if minimam > abs(take[i]-length)+ret:
            minimam = abs(take[i]-length)+ret
            sayonara = copy.copy(data)
    k = 0
    for j in range(len(sayonara)):
        if sayonara[j] == 1:
            del l[j-k]
            k += 1
    ans += minimam
    
print ans