import time

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

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

INF = 10 ** 8

stack = []
depth, a, b, c, mp = 0, 0, 0, 0, 0
stack.append([depth, a, b, c, mp])
flg = []

MP = INF

ct = 0
while stack:
    x = stack.pop(-1)
    if x[0] == N:
        a, b, c = x[1], x[2], x[3]
        mp = x[4] + abs(a-A) + abs(b-B) + abs(c-C) - 30
        if min(a, b, c) > 0 and mp < MP:
            MP = mp
    elif x[0] > N:
        pass
    else:
        tmp = tuple(x)
        for i in range(4):
            if i == 0:
                x[0] += 1
            else:
                x[0] += 1
                x[i] += l[x[0]-1]
                x[4] += 10
            if x not in flg:
                stack.append(x)
                flg.append(tuple(x))
            x = list(tmp)
print(MP)
