def dfs(i, a, b, c, plus):
    global ans

    if i == n:
        if a and b and c:
            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10
            ans = min(ans, mp)

    else:
        dfs(i + 1, a, b, c, plus)
        dfs(i + 1, a + l[i], b, c, plus + 1)
        dfs(i + 1, a, b + l[i], c, plus + 1)
        dfs(i + 1, a, b, c + l[i], plus + 1)


n, A, B, C = map(int, input().split())
l = [int(input()) for i in range(n)]

ans = float("inf")

dfs(0, 0, 0, 0, 0)

print(ans) def dfs(i, a, b, c, plus):
    global ans

    if i == n:
        if a and b and c:
            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10
            ans = min(ans, mp)

    else:
        dfs(i + 1, a, b, c, plus)
        dfs(i + 1, a + l[i], b, c, plus + 1)
        dfs(i + 1, a, b + l[i], c, plus + 1)
        dfs(i + 1, a, b, c + l[i], plus + 1) dfs global ans if i == n:
        if a and b and c:
            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10
            ans = min(ans, mp)

    else:
        dfs(i + 1, a, b, c, plus)
        dfs(i + 1, a + l[i], b, c, plus + 1)
        dfs(i + 1, a, b + l[i], c, plus + 1)
        dfs(i + 1, a, b, c + l[i], plus + 1) i == n i n if a and b and c:
            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10
            ans = min(ans, mp)

     a and b and c a and b a b c mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10 mp abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10 abs(a - A) + abs(b - B) + abs(c - C) abs(a - A) + abs(b - B) abs(a - A) abs a - A a A abs(b - B) abs b - B b B abs(c - C) abs c - C c C (plus - 3) * 10 plus - 3 plus 3 10 ans = min(ans, mp) ans min(ans, mp) min ans mp dfs(i + 1, a, b, c, plus) dfs i + 1 i 1 a b c plus dfs(i + 1, a + l[i], b, c, plus + 1) dfs i + 1 i 1 a + l[i] a l[i] l i b c plus + 1 plus 1 dfs(i + 1, a, b + l[i], c, plus + 1) dfs i + 1 i 1 a b + l[i] b l[i] l i c plus + 1 plus 1 dfs(i + 1, a, b, c + l[i], plus + 1) dfs i + 1 i 1 a b c + l[i] c l[i] l i plus + 1 plus 1 i i a a b b c c plus plus n, A, B, C = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split A B C int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input l = [int(input()) for i in range(n)] l [int(input()) for i in range(n)] ans = float("inf") ans float("inf") float "inf" dfs(0, 0, 0, 0, 0) dfs 0 0 0 0 0 print(ans) print ans A, B, C = map(int, input().split()) map(int, input().split()) A ans = float("inf") float("inf") ans n, A, B, C = map(int, input().split()) map(int, input().split()) n l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l def dfs(i, a, b, c, plus):
    global ans

    if i == n:
        if a and b and c:
            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10
            ans = min(ans, mp)

    else:
        dfs(i + 1, a, b, c, plus)
        dfs(i + 1, a + l[i], b, c, plus + 1)
        dfs(i + 1, a, b + l[i], c, plus + 1)
        dfs(i + 1, a, b, c + l[i], plus + 1) def dfs(i, a, b, c, plus):
    global ans

    if i == n:
        if a and b and c:
            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10
            ans = min(ans, mp)

    else:
        dfs(i + 1, a, b, c, plus)
        dfs(i + 1, a + l[i], b, c, plus + 1)
        dfs(i + 1, a, b + l[i], c, plus + 1)
        dfs(i + 1, a, b, c + l[i], plus + 1) dfs B, C = map(int, input().split()) map(int, input().split()) B C = map(int, input().split()) map(int, input().split()) C
def dfs(i, a, b, c, plus):
    global ans

    if i == n:
        if a and b and c:
            mp = abs(a - A) + abs(b - B) + abs(c - C) + (plus - 3) * 10
            ans = min(ans, mp)

    else:
        dfs(i + 1, a, b, c, plus)
        dfs(i + 1, a + l[i], b, c, plus + 1)
        dfs(i + 1, a, b + l[i], c, plus + 1)
        dfs(i + 1, a, b, c + l[i], plus + 1)


n, A, B, C = map(int, input().split())
l = [int(input()) for i in range(n)]

ans = float("inf")

dfs(0, 0, 0, 0, 0)

print(ans)