N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return  abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c)
    ret2 = dfs(cur + 1, a, b + l[cur], c)
    ret3 = dfs(cur + 1, a, b, c + l[cur])
    return min(ret0, ret1, ret2, ret3)

print(dfs(ret0, ret1, ret2, ret3))
