N, A, B, C = map(int, input().split())

l = [int(input()) for i in range(N)]

stack = []
stack.append((0, (0, 0, 0), 0))
flg = []
mp = []

while stack:
    x = stack.pop(-1)
    if x[0] == N:
        a = x[1][0]
        b = x[1][1]
        c = x[1][2]
        if min(a, b, c) > 0:
            sum_mp = x[2] + abs(a-A)+abs(b-B)+abs(c-C)
            mp.append(sum_mp)
    else:
        depth = x[0]
        bamboo = x[1]
        MP = x[2]
        for i in range(4):
            bb = list(bamboo)
            if i < 3:
                if bb[i] != 0 and bb[i] < [A, B, C][i]:
                    mm = MP + 10
                    bb[i] += l[depth]
                    if (depth+1, bb, mm) not in flg:
                        stack.append((depth+1, bb, mm))
                        flg.append((depth+1, bb, mm))
                elif bb[i] == 0:
                    mm = MP
                    bb[i] += l[depth]
                    if (depth+1, bb, mm) not in flg:
                        stack.append((depth+1, bb, mm))
                        flg.append((depth+1, bb, mm))
            else:
                mm = MP
                if (depth+1, bb, mm) not in flg:
                    stack.append((depth+1, bb, mm))
                    flg.append((depth+1, bb, mm))

print(min(mp))
